Skip to main content

Lineage full export

Use Lakehouse to export a unified view of lineage that you can reuse across impact analysis, dashboard impact, root cause analysis, and other lineage use cases.

Before you begin

Before you run these queries, make sure:

  • Your Lakehouse setup is complete and Lakehouse is enabled for your organization. If setup isn't complete, see Get started with Lakehouse.
  • The LINEAGE table is set up in your warehouse. This table is not part of the native GOLD namespace and must be created separately. See Set up lineage tables.

Full lineage export

These queries use the ASSETS table from the GOLD namespace in the Lakehouse catalog and the LINEAGE table, which you create separately in your warehouse (see Set up lineage tables).

The query returns lineage rows for assets updated in the last 2 days, including upstream and downstream dependencies. Use it to monitor recent updates, identify downstream dependencies for impact analysis, trace upstream sources during root cause investigations, and validate lineage changes after deployments.

The output includes the depth of each connection, which helps distinguish direct and indirect dependencies.

-- ============================================
-- FULL LINEAGE EXPORT
-- gold.assets: Lakehouse catalog (GOLD namespace)
-- LINEAGE: Customer-managed table (see "Set up lineage tables")
-- ============================================
SELECT
a.guid, -- Starting asset's unique identifier
a.asset_name, -- Starting asset name (e.g., DIM_CUSTOMERS)
a.asset_qualified_name, -- Full path including connection/database/schema
a.asset_type, -- Asset type (Table, View, Dashboard, etc.)
TO_TIMESTAMP_LTZ(a.updated_at / 1000) AS LAST_UPDATED, -- Convert epoch milliseconds to timestamp
DATEDIFF(
day,
TO_TIMESTAMP_LTZ(a.updated_at / 1000),
CURRENT_TIMESTAMP()
) AS DAYS_SINCE_UPDATE, -- Number of days since last update
l.start_name, -- Lineage start point name
l.start_type, -- Type at lineage start
l.related_name, -- Related asset name in the lineage path
l.related_type, -- Related asset type (Table, Dashboard, etc.)
l.direction, -- UPSTREAM (sources) or DOWNSTREAM (consumers)
l.level -- Depth in lineage (1=direct, 2=2-hops, etc.)
FROM gold.assets a
INNER JOIN LINEAGE l
ON a.guid = l.start_guid -- Join on asset identifier
WHERE
a.has_lineage -- Only include assets with lineage relationships
AND a.connector_name IN ('snowflake', 'redshift', 'bigquery') -- Focus on major data warehouses
AND DATEDIFF(
day,
TO_TIMESTAMP_LTZ(a.updated_at / 1000), -- Convert epoch milliseconds to timestamp
CURRENT_TIMESTAMP()
) <= 2 -- Only assets updated within last 2 days
GROUP BY
a.guid, a.asset_name, a.asset_qualified_name, a.asset_type,
a.updated_at,
l.start_name, l.start_type, l.related_name, l.related_type,
l.direction, l.level
ORDER BY
a.updated_at DESC, -- Most recently updated first
a.asset_qualified_name, -- Then group by asset
l.direction, -- Show upstream first, then downstream
l.level -- Order by proximity (closest first)
LIMIT 200;
Sample output
ASSET_NAMEASSET_TYPERELATED_NAMERELATED_TYPEDIRECTIONLEVEL
ACCOUNT_IDColumnACCOUNT_IDPowerBIColumnDOWNSTREAM1
ASSESSMENT_IDColumnASSESSMENT_IDPowerBIColumnDOWNSTREAM1
CREDIT_LIMITColumnCREDIT_LIMITPowerBIColumnDOWNSTREAM1
CREDIT_SCOREColumnCREDIT_SCOREPowerBIColumnDOWNSTREAM1
CREDIT_SCOREColumnExecutive OverviewPowerBIPageDOWNSTREAM2
CURRENT_BALANCEColumnCURRENT_BALANCEPowerBIColumnDOWNSTREAM1
CUSTOMER_IDColumnCUSTOMER_IDPowerBIColumnDOWNSTREAM1
CUSTOMER_IDColumnExecutive OverviewPowerBIPageDOWNSTREAM2
DEBT_TO_INCOME_RATIOColumnDEBT_TO_INCOME_RATIOPowerBIColumnDOWNSTREAM1
EXPOSURE_AT_DEFAULTColumnEXPOSURE_AT_DEFAULTPowerBIColumnDOWNSTREAM1
PROBABILITY_OF_DEFAULTColumnPROBABILITY_OF_DEFAULTPowerBIColumnDOWNSTREAM1
RECENT_INQUIRIESColumnRECENT_INQUIRIESPowerBIColumnDOWNSTREAM1
RISK_GRADEColumnRISK_GRADEPowerBIColumnDOWNSTREAM1
LAST_UPDATEColumnLast UpdateSigmaDataElementFieldDOWNSTREAM1
CART_TAXTableosha_inspectionTableDOWNSTREAM1