pub fn lineage(
column: &str,
statement: &Statement,
schema: &MappingSchema,
config: &LineageConfig,
) -> LineageResult<LineageGraph>Expand description
Build lineage for a specific output column in a SQL statement.
§Arguments
column- The name of the output column to trace (can include table qualifier).statement- The parsed SQL statement.schema- Schema information for table/column resolution.config- Configuration options.
§Returns
A LineageGraph rooted at the target column, showing its upstream lineage.
§Errors
Returns LineageError::ColumnNotFound if the column is not in the output.
§Example
use sqlglot_rust::parser::parse;
use sqlglot_rust::dialects::Dialect;
use sqlglot_rust::optimizer::lineage::{lineage, LineageConfig};
use sqlglot_rust::schema::MappingSchema;
let sql = "SELECT a, b AS c FROM t";
let ast = parse(sql, Dialect::Ansi).unwrap();
let schema = MappingSchema::new(Dialect::Ansi);
let config = LineageConfig::default();
let graph = lineage("c", &ast, &schema, &config).unwrap();
assert_eq!(graph.node.name, "c");