Commit 982666b
feat(googlesql/parser-ddl-spanner): CHANGE STREAM / SEQUENCE / ROLE / LOCALITY GROUP / PROTO BUNDLE + role GRANT (#246)
Implements the Spanner-specific object DDL the legacy ANTLR grammar has no
first-class rule for (it rides them on the generic-entity hook or rejects them):
- CREATE/ALTER/DROP CHANGE STREAM (truth1 DDL-024/025/026)
- CREATE/ALTER/DROP SEQUENCE (DDL-027/028/029)
- CREATE/DROP ROLE (DDL-032/033)
- role-based GRANT/REVOKE: `… TO/FROM ROLE r [, ...]` and
`GRANT/REVOKE ROLE r [, ...] TO/FROM ROLE r [, ...]`, plus the Spanner
comma-separated object list `ON TABLE t1, t2 TO ROLE r` (DDL-034-037)
- CREATE/ALTER/DROP LOCALITY GROUP (DDL-041/042/043)
- CREATE/ALTER PROTO BUNDLE (DDL-046/047)
New AST nodes (parsenodes.go + nodetags.go + regenerated walk_generated.go) plus
a GranteeRole grantee kind and Roles/Paths fields on the shared GrantStmt/
RevokeStmt so one union parser serves both the legacy ZetaSQL string-grantee
dialect and the Spanner role dialect. Dispatch wired in create_table.go /
alter_table.go / drop.go (the CHANGE/LOCALITY bare-identifier words and the
SEQUENCE/PROTO keywords) and in grant_revoke.go (role-grant disambiguation +
comma-object head). analysis/classify.go classifies the new nodes as DDL.
Authoritative oracle: the live Cloud Spanner emulator (docs/migration/googlesql/
oracle.md). PROVE gate = spanner_ddl_oracle_test.go differential, both polarities
(81 fixtures, omni == emulator). Spanner is authoritative for these forms.
Owned divergences closed:
- #112 INTERLEAVE IN PARENT ON DELETE made OPTIONAL (defaults to NO ACTION) in
create_table.go — the original port over-rejected the documented default.
- #8 inline column PRIMARY KEY already accepted (matches emulator) — guarded.
Flagged (oracle non-authoritative / docs-backed): #128 column-level GRANT, and the
central "Spanner object DDL is first-class, not generic-entity" dialect divergence.
Cross-model (Codex) review caught 3 real bugs (now fixed + regression-tested):
role-grant misroute of legacy `GRANT ROLE ON …`, over-permissive non-ROLE
role-grant target, and over-rejected comma-separated object lists. Oracle-driven
follow-ups: role names are single identifiers (CREATE ROLE rejects dotted; DROP
ROLE accepts), comma-object lists require a type keyword + ROLE grantees, and
PROTO BUNDLE lists allow a trailing comma (change-stream column lists do not).
go test ./googlesql/{parser,ast,analysis}/ green; differential green; vet clean.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 9ab73eb commit 982666b
15 files changed
Lines changed: 2441 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
152 | 160 | | |
153 | 161 | | |
154 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
64 | 83 | | |
65 | 84 | | |
66 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
145 | 166 | | |
146 | 167 | | |
147 | 168 | | |
| |||
361 | 382 | | |
362 | 383 | | |
363 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
364 | 413 | | |
365 | 414 | | |
366 | 415 | | |
| |||
0 commit comments