Repository navigation
perf: borrow source column sets in qualification; linear scopes for commented set operations - #33
Merged
Merged
Conversation
A line or block comment before UNION, INTERSECT or EXCEPT makes the parser wrap the preceding operand in a comment annotation. The shallow branch copy from the linear set-operation scope build did not look through that wrapper, so every level of a commented chain copied all earlier branches again and scope building, validation and analysis grew quadratically. Branch scopes now keep the comment wrapper around the shallow copy, and a wrapped set-operation operand gets the same NULL placeholder as a bare one. The scope tree shape and all validation, analysis and lineage results are unchanged.
Schema-aware column qualification copied work proportional to the whole query or relation for every column reference and nesting level: - Each reference copied its source's complete column list, ambiguity checks copied and normalized the column lists of every source, and table lookup copied the unambiguous-column map. The resolver now normalizes each source's columns once and answers these lookups from borrowed sets, and caches correlated outer-scope lookups. - Each SELECT built and copied the complete scope tree of its query, and copied that scope again for nested queries. Qualification now builds only the selected sources of the SELECT and passes enclosing scopes by reference. - Clauses, nested queries, outputs and GROUP BY projections were copied before rewriting; they are now moved, and star expansion returns early when no star is projected. Wide relations and SELECT * over derived tables now qualify in time linear in their width, and nested derived tables no longer rebuild every nested scope at each level. Qualified output and all validation, analysis and lineage results are unchanged.
This was referenced Oct 3, 2026
Merged
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.
Why
SELECT *subqueries scaled badly (16 wide joins: 93 ms).UNION ALLchains stayed quadratic.Changes
Verification