Skip to content

Parse Snowflake ROLLUP, CUBE and GROUPING SETS as their own nodes - #141

Closed
kvlonge wants to merge 5 commits into
mainfrom
fix/d322-grouping-nodes
Closed

kvlonge wants to merge 5 commits into
mainfrom
fix/d322-grouping-nodes

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

From the corpus run on 78910c3: give the everyday GROUP BY forms ROLLUP, CUBE and GROUPING SETS structured parse nodes, so rules can be written for them.

The change

GROUP BY ROLLUP (…), CUBE (…) and GROUPING SETS (…), at the top level or nested inside GROUPING SETS, parsed as generic function calls named ROLLUP, CUBE and "GROUPING SETS". Refusals named them fn:ROLLUP, fn:CUBE and fn:GROUPING SETS. In parser/_helpers/queries/clauses.rs they now parse to the existing Expression::Rollup, Cube and GroupingSets nodes, so refusals read node:rollup, node:cube and node:grouping_sets. The semantics paths (scope rules, query lineage) already handle these variants.

  • form-links.toml links the three node constructs to their forms. GROUPING SETS gains the link its held obligations were waiting on.
  • No conversion rule is added; the three forms still refuse with SQ0002 until C's rules land. A plain GROUP BY is unchanged.

The other everyday forms

The other forms from that run already have structured nodes on main and only need rules: SAMPLE/TABLESAMPLE (table.table_sample), AT time travel (table.when), TOP (select.top), NATURAL JOIN (joins[].kind), * RENAME (star.rename), LATERAL subqueries (subquery.lateral, joins[].this.lateral) and WITH RECURSIVE (with.recursive).

Syntax coverage

The new parse trees change the fingerprints of sf.query.group-by-cube, group-by-grouping-sets and group-by-rollup. Their definitions are unchanged, and their obligations stay fully met (55/55, 105/105, 55/55). The auditor re-reviewed all three at the new parser tree (review auditor-query-011, commit ce083ff), and syntax-coverage diff reports no regression.

Tests

test_parser gains rows for the three nodes, top-level and nested.

Polyglot check

polyglot keeps these as function calls, so its own grouping-sets tests now differ. A new [[structured_call]] kind in corpora/polyglot-check/expected_differences.toml accepts the difference only when the trees are equal once each listed node, holding only expressions, is written back as polyglot's call; any other difference still fails.

Gate

Pre-gate on f26178d (ce083ff + clean merge of main 9c008e0 + the polyglot-check structured-call entries; 78f05b0 adds only a notes wording change), every .rs touched before the build:

  • make check-merge: exit 0, 24/24 test binaries, including the polyglot exact test in the gate profile.
  • sqlquack verify --require-verified --strict-errors --python: 12,033 cases, 0 failed; 226 of 226 equivalences and rules verified.
  • syntax-coverage results … --against main 9c008e0's baseline: 0 regressions, 0 other changes.
  • syntax-coverage stale: none; diff: 0 problems.
    At its slot: merge current main, re-gate the exact head, then fast-forward.

Audited: approved at 381ff30 (review entry ce083ff) and the polyglot delta at f26178d (record 31cd564). GitHub Actions is blocked by billing; the local D94 gate counts. Queued after #130 and its t006 delta.

GROUP BY ROLLUP (…), CUBE (…) and GROUPING SETS (…), at the top level
or nested in GROUPING SETS, were generic function calls named ROLLUP,
CUBE and "GROUPING SETS". They are now Rollup, Cube and GroupingSets
nodes, so rules can match them and refusals name node:rollup,
node:cube and node:grouping_sets. The form links follow, and GROUPING
SETS gains the link its held obligations waited on.
…322)

polyglot keeps GROUP BY ROLLUP (...), CUBE (...) and GROUPING SETS (...)
as function calls, so its own grouping tests now differ from SQLQuack's
rollup, cube and grouping_sets nodes. A structured_call entry names a
SQLQuack node and polyglot's call; the check counts the difference as
structured only when the trees are equal once each listed node holding
only expressions is written back as that call, so any other difference
still fails.
The three polyglot-check notes for ROLLUP, CUBE and GROUPING SETS named a
decision number; the repository keeps those out of new text.

kvlonge commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing: SQLQuack lands through local-gate trains, not PR merges (D94), so open PRs only add clutter (D628/D630). The branch is kept. Any work here that isn't on main yet is tracked by the train owner and lands through a train.

@kvlonge kvlonge closed this Nov 8, 2026
@kvlonge
kvlonge deleted the fix/d322-grouping-nodes branch November 9, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant