Skip to main content

lineage

Function lineage 

Source
pub fn lineage(
    column: &str,
    sql: &Expression,
    dialect: Option<DialectType>,
    trim_selects: bool,
) -> Result<LineageNode>
Expand description

Build the lineage graph for a column in a SQL query

§Arguments

  • column - The column name to trace lineage for
  • sql - The SQL expression (SELECT, UNION, etc.)
  • dialect - Optional dialect for parsing
  • trim_selects - If true, trim the source SELECT to only include the target column

§Returns

The root lineage node for the specified column

§Example

use polyglot_sql::lineage::lineage;
use polyglot_sql::parse_one;
use polyglot_sql::DialectType;

let sql = "SELECT a, b + 1 AS c FROM t";
let expr = parse_one(sql, DialectType::Generic).unwrap();
let node = lineage("c", &expr, None, false).unwrap();