2.2. How to Query the Lineage Mart

Important

The Lineage Mart should be accessed via the function lin_gen_lineage or lin_live_lineage to ensure correct and performant data retrieval as it abstracts the internal complexity which is matter of change. brackets.

Instead, use the provided abstraction functions to retrieve lineage.

2.2.1. Using LIN_GEN_LINEAGE

The LIN_GEN_LINEAGE function retrieves the persisted, pre-calculated lineage for a given item based on the batch run.

1-- Find all downstream dependencies (sources) for a specific target object
2 select * from (
3    import from script lin_gen_lineage with
4    direction='DOWN' start_schema='PSV_CORE_BA' start_table='CUSTOMER' start_column='SURENAME'
5 );

See LIN_GEN_LINEAGE Reference for details on how to generate lineage via the SQL-interface.

2.2.2. Using LIN_LIVE_LINEAGE

For ad-hoc live parsing of a specific SQL statement against the current metadata snapshot:

1-- Generate live lineage for a specific query
2SELECT * FROM (
3    IMPORT FROM SCRIPT "REDLIN"."LIN_LIVE_LINEAGE" WITH
4    TARGET_SQL = 'with x as (SELECT 3 + 2 AS col_c), y as (select 5 as col_a) select col_c*col_a as col_b from x join y on col_c=col_a'
5);

See LIN_LIVE_LINEAGE Reference for details on how to generate lineage via the SQL-interface.