public final class StatementLineageExtractor extends Object
SELECT
statement (contract §5 two-pass decision procedure).
The extractor wraps SqlSemanticAnalyzer.analyze(java.lang.String, gudusoft.gsqlparser.EDbVendor) as the
semantic gate and relation-binding source (alias → base table), and
walks the already-parsed resolver2-annotated AST for everything the
Semantic IR does not yet carry (expression text, alias/expression
source spans, CASE branch attribution, per-conjunct predicate
decomposition — the IR side arrives with US-021a).
Pass 1 — axis. VALUE contributions come from the SELECT list (one edge per distinct source column per output), ROW contributions from WHERE / HAVING conjuncts (R1) and JOIN ON conjuncts (R2), each targeting the statement's result set as a whole (null target column). A source appearing on both axes yields two edges (identity layer requirement).
Pass 2 — role within axis. ROW: FILTER (R1) beats JOIN (R2); a source in both WHERE and ON yields the FILTER edge only. VALUE: AGGREGATE (V1, incl. reducing window functions, excl. ranking) beats CONDITION (V2, CASE/IIF condition branch) beats TRANSFORM (V3); a bare-column projection is DIRECT (V5); an output with no column sources at all is DERIVED with a null source endpoint (V6). LOOKUP (V4) requires catalog key metadata and is never guessed — it always falls through until the BindingGate story (US-025) supplies key facts.
Out-of-scope statement shapes (set operators, star projections, multi-block queries with CTEs/subqueries, non-TABLE relations) yield no edges — their extraction stories are US-022+.
Internal API: not part of the public gsqlparser surface.
| Modifier and Type | Method and Description |
|---|---|
static List<ContractEdge> |
extract(TSelectSqlStatement stmt,
String statementText,
int statementIndex,
String queryFingerprint,
EDbVendor vendor,
Catalog catalog,
LineageConfig config,
String artifactLocator,
String unitText)
Extract contract edges for one parsed SELECT statement.
|
public static List<ContractEdge> extract(TSelectSqlStatement stmt, String statementText, int statementIndex, String queryFingerprint, EDbVendor vendor, Catalog catalog, LineageConfig config, String artifactLocator, String unitText)
stmt - resolver2-annotated AST from the unit parsestatementText - verbatim statement slice (trailing separator
excluded — the FINGERPRINT-V1 slice)statementIndex - 1-based source-order indexqueryFingerprint - FINGERPRINT-V1 of statementTextunitText - full unit text (token offsets index into it)