feat(bigquery): parse GoogleSQL set-operation column matching - #8
Merged
moshap-firebolt merged 1 commit intoAug 18, 2026
Merged
Conversation
moshap-firebolt
force-pushed
the
moshap/bigquery-setop-corresponding
branch
from
August 14, 2026 18:51
12fd2e2 to
0792fab
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0792fab. Configure here.
Parse the GoogleSQL/BigQuery set-operation column-matching grammar:
query_expr
[ { INNER | [ { FULL | LEFT } [ OUTER ] ] } ]
{ UNION | INTERSECT | EXCEPT } { ALL | DISTINCT }
[ { BY NAME [ ON (cols) ] | [ STRICT ] CORRESPONDING [ BY (cols) ] } ]
query_expr
AST: `SetExpr::SetOperation` (and the `UNION`/`INTERSECT`/`EXCEPT` pipe
operators) gain a `mode: Option<SetOperationMode>` column-propagation prefix
(`INNER`/`LEFT`/`FULL`, each `LEFT`/`FULL` with an optional `OUTER`) and a
`column_match: Option<SetOperationColumnMatch>` trailing clause carrying the
spelling (`BY NAME` vs `CORRESPONDING`), the `STRICT` flag, and the explicit
column list. `BY NAME` moves out of `SetQuantifier` into `column_match`, so the
quantifier is once again just `ALL`/`DISTINCT`; DuckDB's `UNION BY NAME` uses
the same representation.
`BY NAME` and `CORRESPONDING` are kept distinct (they differ in default
semantics and in the column-list keyword), the mode prefix is recognized only
in the slot immediately before the operator -- and is not captured as a
preceding select item's alias -- and `STRICT` is parsed only as part of
`STRICT CORRESPONDING`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
moshap-firebolt
force-pushed
the
moshap/bigquery-setop-corresponding
branch
from
August 16, 2026 17:30
0792fab to
23132a2
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.

What
Parse GoogleSQL/BigQuery set-operation column matching:
Today the fork parses only
UNION [ALL|DISTINCT] BY NAME; the mode prefix (INNER/LEFT/FULL/STRICT) and the explicit column list (ON (...)/BY (...)) fail to parse.How
SetOperationMode { None, Inner, Left, Full, Strict }and two fields onSetExpr::SetOperation:mode(the prefix) andcorresponding_columns: Option<Vec<Ident>>(theON/BYlist). The existingSetQuantifier(ALL/DISTINCT/ByName) is kept as-is, not overloaded.parse_query_bodyonly when a set operator actually follows (lookahead), soINNER JOINetc. are untouched.CORRESPONDING/CORRESPONDING BY (...)are equivalent spellings ofBY NAME/BY NAME ON (...);Displaycanonicalizes to theBY NAMEspelling and round-trips (verified_stmt).Test
tests/sqlparser_bigquery.rs::parse_set_operation_by_nameasserts the mode + column list on the AST; representative forms (INNER/FULL/LEFT ... UNION ALL BY NAME [ON (cols)],CORRESPONDING BY (...)) round-trip.Consumed by Firebolt's
dialect=bigqueryset-operation lowering. Upstream PR to follow separately.🤖 Generated with Claude Code
Note
Medium Risk
Breaking AST shape change on
SetExpr::SetOperationfor downstream pattern matches, plus subtle lexer disambiguation between set-op modes and JOIN keywords.Overview
Extends BigQuery/GoogleSQL set-operation column matching so queries like
FULL UNION ALL BY NAME ON (a, b)andLEFT UNION ALL CORRESPONDING BY (a)parse into the AST instead of failing.SetExpr::SetOperationgainsmode(SetOperationMode:INNER/LEFT/FULL/STRICT, with optionalOUTER) andcorresponding_columnsfor explicitON (...)/BY (...)lists.Displayprints the mode prefix andON (...)list;CORRESPONDINGspellings normalize toBY NAME/BY NAME ON (...)on round-trip.The parser peeks the mode prefix only when a set operator follows (so
INNER JOINetc. stay unchanged), acceptsCORRESPONDINGalongside existingBY NAMEquantifiers, and wires the new fields throughparse_remaining_set_exprs. Existing tests that constructSetOperationmanually are updated for the new fields.Reviewed by Cursor Bugbot for commit 0792fab. Bugbot is set up for automated code reviews on this repo. Configure here.