Repository navigation
tp: let semantic analysis see CTEs - #7643
Merged
Merged
Conversation
LalitMaganti
added this pull request to stack #7645
September 27, 2026 20:08
LalitMaganti
removed this pull request from stack #7645
September 27, 2026 20:08
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 27, 2026 20:43
c024449 to
8ca182d
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 27, 2026 21:13
8ca182d to
9c25c8f
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 27, 2026 22:55
9c25c8f to
3124216
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
2 times, most recently
from
September 27, 2026 23:45
1673785 to
7ff5acd
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 28, 2026 03:53
7ff5acd to
9e2c303
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 28, 2026 04:21
9e2c303 to
502bb9c
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 28, 2026 05:28
502bb9c to
9380a1c
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 28, 2026 06:06
9380a1c to
eeb1d9a
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
2 times, most recently
from
September 29, 2026 15:34
07466a2 to
d735e3f
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 29, 2026 15:45
d735e3f to
0df32ce
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 29, 2026 17:13
c6a734a to
c7d39cf
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 29, 2026 17:36
c7d39cf to
2cddcca
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 29, 2026 17:59
2cddcca to
8cf3966
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 29, 2026 18:20
8cf3966 to
0602c38
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 29, 2026 19:04
0602c38 to
89d15cb
Compare
LalitMaganti
marked this pull request as ready for review
September 29, 2026 19:18
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
September 29, 2026 19:44
89d15cb to
f1330bb
Compare
sashwinbalaji
approved these changes
Sep 30, 2026
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
October 1, 2026 00:17
f1330bb to
4503200
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
2 times, most recently
from
October 1, 2026 00:41
f5b8ed1 to
120223e
Compare
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
2 times, most recently
from
October 1, 2026 00:51
5c833f0 to
c199ff4
Compare
No behaviour change. A pipeline source and each intersection operand now go through one step, CompileRelation, which gives the plan node and columns of what the source reads, and the names in scope while a pipeline is compiled live together in one Scope. Also renames MacroRewriteBuilder to RewriteTree, as syntaqlite calls these rewrites.
Semantic analysis skipped the definitions of a WITH clause, so a query reading a CTE could not be described: a pipeline could not read SQL which uses one. Each CTE is now in scope for the rest of its WITH clause and the query it belongs to, hiding any relation of the same name there, as in SQLite. A view still sees only what its name meant where it was defined, and a recursive CTE reads itself as a relation of unknown shape. What is analyzed is also read where it is in its statement: a query, or a relation named at some node, sees the CTEs in scope there. So the SQL a pipeline reads can name a CTE of the statement the pipeline is written in, once pipelines can be written inside one.
LalitMaganti
force-pushed
the
dev/lalitm/analysis-cte-scopes
branch
from
October 1, 2026 01:29
c199ff4 to
e5a8795
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Semantic analysis skipped the definitions of a
WITHclause, so a query reading a CTE could not be described, and a pipeline could not read SQL which uses one:Now each CTE is in scope for the rest of its
WITHclause and the query it belongs to, hiding any relation of the same name there, as in SQLite:What is analyzed is also read where it is in its statement:
AnalyzeQuery(query)andAnalyzeRelation(at, name)see the CTEs in scope at that node. The analyzer finds them by following its own walk down to the node (statements,WITHclauses, compound selects,FROMclauses and pipeline sources), defining only the CTEs it passes. So once pipelines can be subqueries, the SQL they read can name a CTE of the statement they are written in: