Open Data Infrastructure
SQLGlot Expression Trees for Governance Review
How SQLGlot expression trees make SQL transformations inspectable for policy review, lineage checks, migration risk, and portability.
SQL review by string search is where governance goes to pretend.
Expression trees expose structure
SQLGlot parses SQL into expression trees. Its documentation describes expression objects, parsing, SQL generation, and AST-based diffing. That matters because governance review needs structure: tables, columns, predicates, joins, functions, casts, and dialect assumptions.
A string diff can tell you text changed. An expression tree can help show what kind of change occurred. Did a predicate move? Did a selected column change? Did a function call shift semantics during migration? Those are governance questions.
Governance needs inspectable transformations
An open data migration should not depend on a pile of unreviewable rewrite scripts. SQLGlot expression trees can help teams classify transformations, compare versions, flag unsupported syntax, and create evidence for reviewers.
This is not magic lineage. Parser-derived evidence has limits. It needs catalog context, runtime context, and tests. But it is much better than pretending that a thousand SQL files can be governed by eyeballing diffs.
Core idea: AST review turns SQL migration from text churn into inspectable change evidence.
The ODI pattern uses parser evidence as one layer
Open Data Infrastructure needs portability across engines, but portability is not only syntax translation. It is meaning preservation. SQLGlot can help inspect syntax and expressions. Catalogs, tests, lineage, and owner review have to validate the meaning.
For more context, read SQLGlot parser coverage, SQLGlot transpilation tests, and SQLGlot ASTs as lineage evidence. The tree is evidence, not the whole courtroom.
What breaks first
Parser evidence fails when teams treat it as a substitute for semantic review.
- A query parses successfully but changes behavior across dialects.
- Column lineage is inferred without catalog aliases or runtime views.
- Policy review sees a table name but misses row-filter behavior.
- Migration approval ignores tests because the AST diff looked small.
Questions to ask in a review
Ask which expression types changed, which dialect assumptions are present, which tables and columns are touched, which policies depend on those columns, and which tests prove equivalent behavior.
A useful governance review does not ask whether the SQL looks familiar. It asks whether the structure still means what the platform thinks it means.
Sources to start with
These primary sources anchor the technical claims in this guide.
- SQLGlot documentation
- SQLGlot expressions API documentation
- SQLGlot diff API documentation
- SQLGlot parser API documentation
Governance starts getting real when SQL becomes inspectable structure.