GET_LINEAGE
Returns upstream or downstream lineage for a table, view, stage, or column. Each returned row represents one source-to-target relationship in the lineage path.
Syntax
GET_LINEAGE(
'<object_name>',
'<object_domain>',
'<direction>'
[, <distance> ]
)
Arguments
Arguments are positional.
Output Columns
Examples
This section provides example queries for tracing lineage.
Find Upstream Tables
This query returns up to two upstream hops for agg_customer_sales:
SELECT
distance,
source_object_catalog,
source_object_database,
source_object_name,
source_object_domain,
target_object_database,
target_object_name
FROM GET_LINEAGE(
'lineage_demo.agg_customer_sales',
'TABLE',
'UPSTREAM',
2
)
ORDER BY distance;
Find Downstream Columns
This query traces where fact_orders.amount is used:
SELECT
distance,
source_object_name,
source_column_name,
target_object_name,
target_column_name
FROM GET_LINEAGE(
'lineage_demo.fact_orders.amount',
'COLUMN',
'DOWNSTREAM',
5
)
ORDER BY distance, target_object_name, target_column_name;
Usage Notes
- If the object exists but has no recorded lineage, the function returns no rows.
- Results are filtered according to the current role's object visibility.
- Stage relationships are object-level only; staged file fields are not returned as stable columns.
- System and
information_schemaobjects are not recorded as lineage sources. - External-catalog objects are returned as terminal endpoints and are not traversed further.
- Use
REFRESH LINEAGEto backfill lineage for views that existed before lineage was enabled.