基于项目 SQL 证据的动态节点搜索与分层数据血缘治理方法

状态:方法论说明。本文总结当前 SQLGlot 项目的实现路径、治理原则,以及与数据溯源研究和行业框架的对应关系;不构成生产执行、运行时血缘或业务口径确认。

一句话定义

基于项目 SQL 证据的动态节点搜索与分层数据血缘治理方法,是指在一个已冻结的项目 SQL 快照中,以待分析目标为起点,自动搜索可关联的 Dataset Node、writer 和上游依赖路径;再在已证实的节点路径和 SQL scope 内执行字段级 DFS。对无法从项目 SQL 证据唯一证明的关系,系统保留歧义证据,并通过人工审核把技术推断转化为可审计的治理结论。

它的目标不是不计代价地补全血缘,而是保证每一条已发布结论都可回到确定的 SQL、表达式、位置和审核决定;不能证明的部分必须明确说明边界。

方法主链

冻结项目 SQL 快照与哈希
  -> SQL AST / statement / scope 解析
  -> 数据集合(Dataset)抽象与节点分类
  -> 项目范围内的 Dataset Node 依赖图与 writer 候选搜索
  -> 从目标节点动态搜索上游节点与路径
  -> 在已证实节点路径中执行字段级 DFS
  -> 分离交付 VALUE 血缘、控制证据、来源分类和业务解释
  -> 人工审核、版本化和可重复生成

这里的“动态”指目标驱动的项目内搜索与遍历:分析器在冻结的项目 SQL 快照中,按待分析目标自动定位节点、搜索可达 writer 和上游边,再展开字段路径。它不表示读取生产运行事件、执行动态 SQL,或把某次运行中的真实数据贡献当作已证明事实。

第一层:项目 SQL 解析与数据集合抽象

首先处理的不是字段,而是冻结项目 SQL 快照中可作为输入、中间结果或输出的数据集合(Dataset)。解析过程以 statement 和 SQLGlot scope 为边界,识别实际被当前 FROM、JOIN、CTE、子查询或集合运算引用的集合。

数据集合的典型来源包括:

  • 物理表或已知写入目标;
  • 本地 SQL 输入中没有 writer 的外部表;
  • CTE;
  • 派生子查询;
  • SELECT 的查询结果;
  • UNION 等集合运算结果。

稳定标识不能只依赖表名。同名表、跨环境逻辑表、同一文件中的多个 statement 或 scope 都可能不同,因此节点标识必须关联源 SQL、statement、scope 等可回溯证据。

第二层:Dataset Node 分类、writer 搜索与依赖图

每个数据集合被归类为 Dataset Node,并由项目 SQL 结构建立有向依赖边:读取、CTE 绑定、派生、集合分支、写入目标和命令目标等。分析器按目标在项目范围内搜索可关联节点和 writer 候选;此时形成的是数据集合级血缘骨架,回答的问题是:

一个目标表或逻辑数据集合,依赖哪些上游数据集合,以及每一段依赖由哪段 SQL 建立?

节点图只表达被实际引用的依赖,不能把“在 scope 中可见但没有被当前语句使用”的 CTE 误记为输入。跨文件逻辑表 writer 的绑定也必须独立为人工可编辑的审核决定:自动发现候选可以提高效率,但程序不得覆盖人工 REJECTED 决定。

第三层:目标驱动的节点搜索与 DFS

在有了 Dataset Node 图后,分析器从一个目标节点沿上游边动态搜索并做 DFS。这一步负责处理整体结构,而非字段语义:

  • CTE、派生查询和嵌套 scope 的展开;
  • UNION 等集合运算分支;
  • 跨文件 writer 绑定;
  • 外部数据集合终点;
  • 循环和无法解析结构的终止与诊断。

节点搜索与 DFS 的输出是一个受项目 SQL 结构约束的上游路径集合。它先限定“值可能经过哪些数据集合”,为字段追踪提供合法上下文;字段 DFS 不应脱离这层图直接在全部 SQL 中按同名字段搜索。

第四层:字段级 DFS

字段 DFS 以 (root_node_id, field_name) 为起点。它在当前节点中找到字段的实际投影表达式,提取表达式引用的输入字段,再只沿节点级 DFS 已证明的输入边向上递归。

每次访问都记录唯一的 tree_id + visit_id、父访问、表达式、输入字段、节点边、源文件、statement、scope 和 SQL 位置。因此,同名字段即使经不同的边或分支进入,也不会在审计中混淆。

字段级 DFS 需要保守处理下列 SQL 结构:

  • SELECT *:只有字段投影证据能唯一定位来源时才透传;
  • 未限定列:多输入 scope 中无法唯一绑定时保留全部候选;
  • UNION:先应用外层投影表达式,再进入集合分支;
  • 动态环境关系:没有本地 writer 时作为带动态标记的外部终点;
  • cycle、缺字段或不可枚举投影:以明确 terminal 原因停止。

AMBIGUOUS_STAR_SOURCES 和 AMBIGUOUS_COLUMN_SOURCES 是诊断证据,不是已确认的 VALUE 来源。它们的作用是完整表达“静态分析不能证明什么”,而不是制造一个看似完整但不可审计的单一路径。

治理控制:从技术血缘到可用结论

1. 证据优先与可复现

输入 SQL、审核表、解析器版本、生成器版本和产物哈希共同构成一次分析的证据链。任何结果都应能定位到源文件、SQL 行范围和生成规则;人工修改 writer 审核表后,必须从节点图开始重建后续字段图。

2. VALUE、控制条件和业务结论分离

字段值的来源与数据适用条件不是同一个概念,应分别保存和交付:

  • VALUE 血缘:字段值的上游字段、常量、表达式和加工路径;
  • 语义控制证据:CASE/IF 条件、可证明的 inner join 条件,以及 WHERE/HAVING/QUALIFY 的行资格条件;
  • 来源分类:仅根据已确认的 VALUE 终点系统映射得出 S1--S4,不把控制条件、表名模式或业务常识伪装为来源证据;
  • 业务说明:基于冻结的技术证据解释字段形成规则和边界,不能由模板或模型补猜业务事实。

3. 人在回路中的决定权

自动化负责解析、发现候选、保存证据和重复验证;人负责确认跨环境 writer、源系统归属、业务含义和生产事实。审核结果应有状态、备注、责任归属和生效时点,并与生成产物关联。

4. 分层交付

同一证据链应面向不同读者提供不同粒度的产物:

  • 节点、边、字段树和 JSONL 明细:程序、审计和技术排障;
  • 字段来源和分类 CSV:数据 Owner、数据治理和变更影响分析;
  • 业务 Markdown:业务人员阅读的形成规则、适用条件、关联规则和原 SQL 位置。

研究与行业定位

这不是一项孤立的 SQL 解析技巧,而是将三类成熟思想组合成适合数据治理的落地方法:

  1. 数据库领域的 Data Provenance / Data Lineage:用转换与派生关系解释数据从何而来、如何形成;
  2. SQL AST 与列级血缘工程:在 SQL scope、投影表达式和输入绑定中提取确定的依赖;
  3. 数据治理框架:将技术证据接入责任、审核、影响分析、质量和合规控制。
方法层 最接近的理论或标准 对应关系
数据集合抽象、节点和依赖边 W3C PROV 将数据集视作 Entity,将 SQL 加工视作 Activity,记录派生关系。
节点图与上游 DFS Data lineage / data provenance 在转换图中追溯输出依赖的上游输入。
字段级 DFS Column-level lineage / where-how provenance 从输出字段沿表达式与输入字段递归回溯。
歧义保留、人工绑定审核 数据治理的控制与责任机制 区分机器可证明、候选、人工批准与人工拒绝。
哈希、定位、可重复生成 可审计 provenance 每条结论都可回到输入版本、SQL 位置和生成规则。
分类、影响分析、业务报告 DAMA / DCAM 将技术血缘转化为数据质量、责任、变更影响和合规治理能力。

最直接的学术对应是数据溯源。Cui 与 Widom 的 Lineage Tracing for General Data Warehouse Transformations 研究如何在一般数据仓库转换图中追溯数据到原始输入,并给出在线性和一般无环转换图中的追踪算法。它与“先抽象数据集合、构建节点图、再 DFS”的路径高度同构;区别是该研究更偏元组级、运行时或通用转换,本项目则以 SQL 源码的静态字段级分析为主。论文原文

另一条理论基础是 why / where / how provenance:where 说明结果字段或值来自哪里,why 说明哪些输入共同导致了结果,how 说明经过了怎样的加工组合。字段 DFS 以静态 SQL 为证据,覆盖字段来源和表达式加工;CASE、UNION、函数、常量和确定的输入字段分支均构成可审计的 how 解释。综述:Provenance in Databases: Why, How, and Where;早期理论:Why and Where: A Characterization of Data Provenance。

在工程实现上,近年的 LINEAGEX 同样通过遍历 SQL 解析树提取列级血缘、处理歧义并用于数据质量排查。本项目的额外治理设计是先从项目 SQL 快照形成稳定的 Dataset Node 图,再以目标为起点自动搜索可达节点、writer 和上游路径,并在既有节点关系和 scope 约束内执行字段 DFS,而不是仅从孤立 SQL 直接抽取列依赖。

W3C PROV 是最值得借鉴的跨系统语义模型:Dataset Node 可映射为 Entity,SQL statement、scope 或 ETL 步骤可映射为 Activity,writer 审核人、数据 Owner 和生成器可映射为 Agent。将这三类对象和 used、generated、derived、associated 关系补充到现有模型,可使技术血缘进一步支持跨系统交换、责任归属和审计表达。PROV-DM / PROV-O

OpenLineage 与本方法相似但不相同:它以运行期 Job、Run、Dataset 事件为核心,记录实际执行的输入、输出、版本和状态;本方法以设计期的项目 SQL 快照为证据,在项目范围内动态搜索节点和路径,解释 CTE、表达式、字段映射和潜在歧义。两者应互补使用:项目节点图与字段图解释设计,运行事件核验实际执行。OpenLineage Specification

DAMA-DMBOK 和 EDM Council DCAM 不规定 DFS 算法,却定义了这项能力进入数据治理体系的原因与组织方式,包括元数据、数据架构、质量、控制环境、责任机制、变更影响和审计。因此,SQLGlot 方法是技术血缘能力底座,DAMA/DCAM 是组织管理、使用和衡量该能力的框架。DAMA-DMBOK / EDM Council DCAM

本方法的治理特色不在于单纯使用 DFS,而在于以下四项原则:

  1. 先集合、后字段,控制复杂度;
  2. 先证据、后结论,不以猜测补全血缘;
  3. 自动发现与人工批准分离,保留责任边界;
  4. 技术明细、分类结果与业务解释分层交付。

与论文、标准和行业框架的关系

本方法要素 对应论文、标准或框架 对应关系与区别
数据集合、加工活动、责任主体与派生关系 W3C PROV-DM / PROV-O Dataset Node 可对应 Entity;SQL statement、scope 或 ETL 步骤可对应 Activity;审核人、系统和 Owner 可对应 Agent。本项目当前以 Dataset Node 图为主,若要跨平台交换,可补充 Entity--Activity--Entity 的表达。
转换图上的上游追溯 Cui & Widom, Lineage Tracing for General Data Warehouse Transformations 该研究讨论一般数据仓库转换图中的血缘追溯算法。它更偏元组级/运行时或通用转换;本方法以 SQL 源码静态解析为输入,并把集合级 DFS 与字段级 DFS 显式分层。
字段来源与加工解释 Buneman, Khanna & Tan, Why and Where: A Characterization of Data Provenance / Cheney, Chiticariu & Tan, Provenance in Databases: Why, How, and Where where 对应字段/值的来源,how 对应表达式、分支和加工路径。项目提供静态字段依赖证据,但不声称得到运行时的逐行或逐元组真实贡献。
SQL AST 中的列级血缘与歧义处理 LINEAGEX: A Column Lineage Extraction System for SQL 同样利用 SQL 解析树提取列级血缘并处理歧义。项目额外强调先构建 Dataset Node 图、复用 scope 上下文、人工 writer 审核和治理交付边界。
运行期 Job/Run/Dataset 血缘 OpenLineage Specification OpenLineage 规范运行时 Job、Run 和 Dataset 事件;本方法规范设计期/静态 SQL 证据。两者互补:静态图可解释设计,运行事件可核验实际执行。
数据治理能力、责任和控制环境 DAMA-DMBOK / EDM Council DCAM 两者提供元数据、数据架构、质量、责任和控制的治理框架,不规定 SQL DFS 算法。本方法可作为其中“技术血缘与可审计元数据”的实现底座。

适用边界

本方法能够证明的是冻结项目 SQL 快照所支持的依赖与加工证据,而不是所有业务事实。项目内节点搜索是动态的,但证据范围仍受该快照约束;下列内容需要独立治理或运行期验证:

  • 参数、分区和运行条件下实际读取的行与实际贡献比例;
  • 存储过程、UDF、动态 SQL、外部任务或未采集脚本内部的逻辑;
  • 来源系统、数据 Owner、指标口径和字段业务含义;
  • S4 等多系统来源是否在某次生产运行中同时实际贡献;
  • 数据质量、权限、敏感数据分级和访问合规结论。

因此,基于项目 SQL 证据的动态节点搜索血缘应被视为数据治理的可审计技术底座,而非替代生产观测、数据责任制或人工业务确认的单一真相源。

建议的正式表述

建议对外使用以下定义:

本项目采用基于项目 SQL 证据的动态节点搜索与分层数据血缘治理方法:先冻结项目 SQL 快照,将其中的物理表、外部表、CTE、派生查询和集合运算结果抽象为可追溯的数据集合节点,构建集合级依赖图;再从目标节点自动搜索项目内可达的 writer、节点和上游路径,并在该路径和 SQL scope 的约束下执行字段级 DFS。系统对无法从项目 SQL 证据唯一证明的关系保留歧义和终止证据,对关键逻辑表绑定和业务归属保留人工审核门,从而把项目 SQL 分析结果转化为可重复、可追溯、可审计的数据治理交付。

Dynamic Node Search and Layered Data Lineage Governance Based on Project SQL Evidence

Status: methodology note. This document summarizes the implementation path of the current SQLGlot project, its governance principles, and its correspondence with data provenance research and industry frameworks; it does not constitute production execution, runtime lineage, or confirmation of business definitions.

One-sentence definition

Dynamic node search and layered data lineage governance based on project SQL evidence means: in a frozen project SQL snapshot, starting from the target under analysis, automatically searching for linkable Dataset Nodes, writers, and upstream dependency paths; then running a field-level DFS inside the proven node paths and SQL scope. For relations that cannot be uniquely proven from project SQL evidence, the system preserves ambiguous evidence, and human review converts technical inference into auditable governance conclusions.

Its goal is not to complete lineage at any cost, but to guarantee that every published conclusion can be traced back to a specific SQL statement, expression, location, and review decision; what cannot be proven must state its boundary explicitly.

Main method chain

Freeze the project SQL snapshot and hash
  -> parse SQL AST / statement / scope
  -> dataset abstraction and node classification
  -> Dataset Node dependency graph inside the project scope and writer candidate search
  -> dynamic search for upstream nodes and paths from the target node
  -> field-level DFS inside the proven node paths
  -> separate delivery of VALUE lineage, control evidence, source classification, and business explanation
  -> human review, versioning, and reproducible generation

"Dynamic" here means target-driven search and traversal within the project: the analyzer automatically locates nodes in the frozen project SQL snapshot according to the target under analysis, searches reachable writers and upstream edges, and then expands field paths. It does not mean reading production run events, executing dynamic SQL, or treating the real data contribution of a particular run as proven fact.

Layer 1: project SQL parsing and dataset abstraction

The first thing processed is not fields, but datasets that can serve as inputs, intermediate results, or outputs in the frozen project SQL snapshot. Parsing is bounded by the statement and the SQLGlot scope, identifying the collections actually referenced by the current FROM, JOIN, CTE, subquery, or set operation.

Typical sources of datasets include:

  • physical tables or known write targets;
  • external tables in local SQL inputs that have no writer;
  • CTEs;
  • derived subqueries;
  • query results of SELECT;
  • results of set operations such as UNION.

A stable identity cannot rely on table names alone. Tables with the same name, logical tables spanning environments, and multiple statements or scopes inside one file may all differ, so node identity must be tied to traceable evidence such as the source SQL, the statement, and the scope.

Layer 2: Dataset Node classification, writer search, and the dependency graph

Each dataset is classified as a Dataset Node, and directed dependency edges are built from the project SQL structure: reads, CTE bindings, derivations, set-operation branches, write targets, and command targets. The analyzer searches for linkable nodes and writer candidates within the project scope according to the target; what forms at this point is a dataset-level lineage skeleton, which answers:

Which upstream datasets does a target table or logical dataset depend on, and which segment of SQL establishes each dependency?

The node graph expresses only dependencies that are actually referenced; a CTE that is "visible in scope but not used by the current statement" must not be recorded as an input. Binding the writer of a cross-file logical table must likewise remain an independently human-editable review decision: automatic discovery of candidates improves efficiency, but the program must not override a human REJECTED decision.

Layer 3: target-driven node search and DFS

With the Dataset Node graph in place, the analyzer searches dynamically upstream from a target node and performs DFS. This step handles overall structure rather than field semantics:

  • expansion of CTEs, derived queries, and nested scopes;
  • set-operation branches such as UNION;
  • cross-file writer binding;
  • external dataset endpoints;
  • termination and diagnostics for cycles and unresolvable structures.

The output of node search and DFS is a set of upstream paths constrained by the project SQL structure. It first bounds "which datasets the value may have passed through", providing a legal context for field tracing; field DFS should not detach from this graph level and search all SQL by same-named fields.

Layer 4: field-level DFS

Field DFS starts from (root_node_id, field_name). It locates the actual projection expression of the field in the current node, extracts the input fields referenced by the expression, and then recurses upward only along input edges proven by the node-level DFS.

Every visit records a unique tree_id + visit_id, the parent visit, the expression, the input fields, the node edge, the source file, the statement, the scope, and the SQL location. Therefore, same-named fields entering through different edges or branches are never confused in an audit.

Field-level DFS must handle the following SQL structures conservatively:

  • SELECT *: passed through only when field projection evidence can locate the source uniquely;
  • unqualified columns: all candidates are kept when the binding is not unique in a multi-input scope;
  • UNION: apply the outer projection expression first, then enter the set branches;
  • dynamic environment relations: without a local writer they become external endpoints carrying a dynamic flag;
  • cycles, missing fields, or non-enumerable projections: stop with an explicit terminal reason.

AMBIGUOUS_STAR_SOURCES and AMBIGUOUS_COLUMN_SOURCES are diagnostic evidence, not confirmed VALUE sources. Their role is to state completely "what static analysis cannot prove", rather than to fabricate a single path that looks complete but cannot be audited.

Governance controls: from technical lineage to usable conclusions

1. Evidence first, reproducibility always

The input SQL, the review table, the parser version, the generator version, and the artifact hashes together form the evidence chain of one analysis. Any result should be locatable to a source file, a SQL line range, and a generation rule; after a human edits the writer review table, the downstream field graph must be rebuilt starting from the node graph.

2. Separating VALUE, control conditions, and business conclusions

The origin of a field value and the conditions under which the data applies are not the same concept and must be stored and delivered separately:

  • VALUE lineage: the upstream fields, constants, expressions, and processing path of a field value;
  • semantic control evidence: CASE/IF conditions, provable inner-join conditions, and the row-qualification conditions of WHERE/HAVING/QUALIFY;
  • source classification: S1--S4 derived only from the confirmed VALUE endpoint system mapping, without disguising control conditions, table-name patterns, or business common sense as source evidence;
  • business explanation: field formation rules and boundaries explained on the basis of frozen technical evidence, with no template or model guessing business facts.

3. Human decision-making in the loop

Automation handles parsing, candidate discovery, evidence storage, and repeated verification; humans confirm cross-environment writers, source-system ownership, business meaning, and production facts. A review result should carry a status, notes, responsibility attribution, and an effective time, and be linked to the generated artifacts.

4. Layered delivery

The same evidence chain should provide artifacts of different granularity for different readers:

  • nodes, edges, field trees, and JSONL details: for programs, audits, and technical troubleshooting;
  • field origin and classification CSVs: for data owners, data governance, and change-impact analysis;
  • business Markdown: formation rules, applicability conditions, association rules, and original SQL locations, written for business readers.

Research and industry positioning

This is not an isolated SQL parsing trick, but a combination of three mature lines of thought into a practical method suited to data governance:

  1. Data Provenance / Data Lineage in the database field: explaining where data comes from and how it was formed through transformation and derivation relations;
  2. SQL AST and column-level lineage engineering: extracting definite dependencies from SQL scope, projection expressions, and input bindings;
  3. data governance frameworks: connecting technical evidence to responsibility, review, impact analysis, quality, and compliance controls.
Method layer Closest theory or standard Correspondence
Dataset abstraction, nodes, and dependency edges W3C PROV Treats datasets as Entity, SQL processing as Activity, and records derivation relations.
Node graph and upstream DFS Data lineage / data provenance Traces the upstream inputs an output depends on through the transformation graph.
Field-level DFS Column-level lineage / where-how provenance Recurses from an output field back through expressions and input fields.
Ambiguity preservation, manual binding review Control and accountability mechanisms of data governance Distinguishes machine-provable, candidate, human-approved, and human-rejected.
Hashing, localization, reproducible generation Auditable provenance Every conclusion can return to the input version, the SQL location, and the generation rule.
Classification, impact analysis, business reporting DAMA / DCAM Turns technical lineage into data quality, accountability, change impact, and compliance governance capability.

The most direct academic counterpart is data provenance. Cui and Widom's Lineage Tracing for General Data Warehouse Transformations studies how to trace data back to original inputs in general data warehouse transformation graphs, and gives tracing algorithms for linear and general acyclic transformation graphs. It is highly isomorphic to the path of "abstract datasets first, build the node graph, then DFS"; the difference is that the research is more tuple-level, runtime, or general-purpose, while this project focuses on static field-level analysis of SQL source code. Paper

Another theoretical foundation is why / where / how provenance: where explains where a result field or value came from, why explains which inputs jointly caused the result, and how explains what processing combination it went through. Field DFS takes static SQL as evidence and covers field origins and expression processing; CASE, UNION, functions, constants, and definite input-field branches all constitute an auditable how explanation. Survey: Provenance in Databases: Why, How, and Where; Early theory: Why and Where: A Characterization of Data Provenance.

On the engineering side, the recent LINEAGEX also extracts column-level lineage by walking SQL parse trees, handles ambiguity, and is used for data quality investigation. The additional governance design of this project is to first form a stable Dataset Node graph from the project SQL snapshot, then automatically search reachable nodes, writers, and upstream paths from the target, and run the field DFS inside existing node relations and scope constraints, rather than extracting column dependencies directly from isolated SQL statements.

W3C PROV is the cross-system semantic model most worth borrowing: a Dataset Node can map to an Entity, a SQL statement, scope, or ETL step to an Activity, and a writer reviewer, data owner, or generator to an Agent. Adding these three kinds of objects and the used, generated, derived, and associated relations to the existing model lets technical lineage further support cross-system exchange, accountability, and audit expression. PROV-DM / PROV-O

OpenLineage is similar to this method but not the same: it centres on runtime Job, Run, and Dataset events, recording the inputs, outputs, versions, and statuses actually executed; this method takes the design-time project SQL snapshot as evidence, dynamically searches nodes and paths inside the project, and explains CTEs, expressions, field mappings, and potential ambiguity. The two should be used as complements: the project node graph and field graph explain the design, run events verify actual execution. OpenLineage Specification

DAMA-DMBOK and EDM Council DCAM do not specify DFS algorithms, yet they define why and how this capability enters a data governance system, including metadata, data architecture, quality, the control environment, accountability, change impact, and audit. So the SQLGlot method is the technical lineage capability foundation, and DAMA/DCAM is the framework for organizing, using, and measuring that capability. DAMA-DMBOK / EDM Council DCAM

The governance character of this method lies not in simply using DFS, but in the following four principles:

  1. datasets before fields, to control complexity;
  2. evidence before conclusions, never completing lineage by guesswork;
  3. automatic discovery separated from human approval, preserving the accountability boundary;
  4. layered delivery of technical detail, classification results, and business explanation.

Relationship to papers, standards, and industry frameworks

Element of this method Corresponding paper, standard, or framework Correspondence and difference
Datasets, processing activities, accountable parties, and derivation relations W3C PROV-DM / PROV-O A Dataset Node can correspond to an Entity; a SQL statement, scope, or ETL step to an Activity; a reviewer, system, or Owner to an Agent. This project currently focuses on the Dataset Node graph; for cross-platform exchange, an Entity--Activity--Entity representation can be added.
Upstream tracing on a transformation graph Cui & Widom, Lineage Tracing for General Data Warehouse Transformations The research discusses lineage tracing algorithms for general data warehouse transformation graphs, leaning more toward tuple-level/runtime or general transformations; this method takes static parsing of SQL source as input and explicitly layers set-level DFS over field-level DFS.
Field origins and processing explanation Buneman, Khanna & Tan, Why and Where: A Characterization of Data Provenance / Cheney, Chiticariu & Tan, Provenance in Databases: Why, How, and Where where corresponds to the origin of fields/values, how to expressions, branches, and processing paths. The project provides static field dependency evidence, but does not claim row-by-row or tuple-by-tuple runtime contributions.
Column-level lineage and ambiguity handling in SQL ASTs LINEAGEX: A Column Lineage Extraction System for SQL Also uses SQL parse trees to extract column-level lineage and handle ambiguity. The project additionally emphasizes building the Dataset Node graph first, reusing scope context, human writer review, and governance delivery boundaries.
Runtime Job/Run/Dataset lineage OpenLineage Specification OpenLineage specifies runtime Job, Run, and Dataset events; this method specifies design-time/static SQL evidence. The two complement each other: the static graph explains design, run events verify actual execution.
Data governance capability, accountability, and control environment DAMA-DMBOK / EDM Council DCAM Both provide a governance framework for metadata, data architecture, quality, accountability, and controls, without specifying SQL DFS algorithms. This method can serve as the implementation foundation for "technical lineage and auditable metadata" inside them.

Applicability boundary

What this method can prove is the dependency and processing evidence supported by the frozen project SQL snapshot, not every business fact. Node search inside the project is dynamic, but the evidence range is still bounded by that snapshot; the following require separate governance or runtime verification:

  • rows actually read and the actual contribution ratio under parameters, partitions, and run conditions;
  • logic inside stored procedures, UDFs, dynamic SQL, external tasks, or uncollected scripts;
  • source systems, data owners, metric definitions, and the business meaning of fields;
  • whether multi-system origins such as S4 actually contributed together in some production run;
  • data quality, permissions, sensitive-data classification, and access-compliance conclusions.

Therefore, lineage by dynamic node search based on project SQL evidence should be treated as an auditable technical foundation for data governance, not as a single source of truth that replaces production observation, data accountability, or human business confirmation.

Recommended formal statement

We recommend the following definition for external use:

This project adopts the dynamic node search and layered data lineage governance method based on project SQL evidence: first freeze the project SQL snapshot, abstract the physical tables, external tables, CTEs, derived queries, and set-operation results inside it into traceable dataset nodes, and build a set-level dependency graph; then automatically search the reachable writers, nodes, and upstream paths inside the project from the target node, and run a field-level DFS under the constraints of those paths and the SQL scope. For relations that cannot be uniquely proven from project SQL evidence, the system preserves ambiguous and termination evidence, and keeps a human review gate for critical logical-table bindings and business attribution, thereby converting project SQL analysis results into reproducible, traceable, and auditable data governance deliverables.