Repository navigation
Parse Spanner-only DDL under a new SPANNER_DDL feature - #2
Merged
Merged
Conversation
Add SPANNER_DDL, a zetajones-only feature (not in MAXIMUM) that parses the Cloud Spanner syntax the GoogleSQL reference parser rejects: all 150 statements in parser/testdata/spanner/**/*.spanner.sql. Reference nodes are reused where Spanner has a GoogleSQL equivalent: - ", ROW DELETION POLICY (...)" / ", OPTIONS (...)" after PRIMARY KEY produce TtlClause / OptionsList, as without the comma; ", INTERLEAVE IN t" is a SpannerInterleaveClause - NOT NULL before DEFAULT/AS joins the attribute list after it, as in SpannerAlterColumnAction; non-stored ALTER COLUMN AS (...) - ARRAY<FLOAT32>(vector_length=>N) is a NamedArgument type parameter - ROLE and PLACEMENT become generic entity types, SYNONYM a generic sub-entity type; dashed database ids; trailing comma in OPTIONS - search/vector index ORDER BY and WHERE reuse OrderBy and WhereClause New nodes (ast/spanner.go) cover GRANT/REVOKE ... TO/FROM ROLE and GRANT ROLE, change streams, proto bundles, queues, ALTER LOCALITY GROUP, identity SKIP RANGE / START COUNTER WITH / ALTER IDENTITY, PLACEMENT KEY, AUTO_INCREMENT, ON UPDATE, table synonyms and ALTER INDEX ADD/DROP STORED COLUMN. DROP CHANGE STREAM / LOCALITY GROUP use DropStatement, and RENAME TABLE takes further pairs. Also implement the reference's CREATE LOCALITY GROUP (FEATURE_CREATE_LOCALITY_GROUP) and CREATE TABLE ttl_clause. The corpus generator now enables +TTL,+CREATE_LOCALITY_GROUP, which turns 8 former backlog statements into golden cases. Two backlog entries missing a semicolon in the docs are reclassified as typos. Tests: TestSpannerOnlySyntax checks that every backlog statement parses with SPANNER_DDL and fails without it; hand-reviewed expected trees live in parser/testdata/extensions/spanner (79 cases, run by TestParser); the fuzz target now also runs with SPANNER_DDL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FTpNRheE3PdSX5XftfH7Nq
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.
Summary
Adds
SPANNER_DDL, a zetajones-only language feature (not a GoogleSQL LanguageFeature, not inMAXIMUM) that parses the Cloud Spanner syntax the reference parser rejects — all 150 statements inparser/testdata/spanner/**/*.spanner.sql. Vendored test behavior is unchanged.Reference nodes reused where Spanner has a GoogleSQL equivalent
, ROW DELETION POLICY (...)/, OPTIONS (...)afterPRIMARY KEY→TtlClause/OptionsList, identical to the reference's comma-less form (verified against the reference binary, offsets aside), INTERLEAVE IN t(noPARENT) →SpannerInterleaveClauseNOT NULLbeforeDEFAULT/AS→ attribute list after the default/generated child, as inSpannerAlterColumnAction; non-storedALTER COLUMN ... AS (...)ARRAY<FLOAT32>(vector_length=>N)→NamedArgumentinTypeParameterListOPTIONSORDER BY/WHERE→OrderBy/WhereClauseNew nodes (
ast/spanner.go, dump ininternal/dump/spanner.go)GRANT/REVOKE … TO/FROM ROLE and GRANT ROLE, change streams, proto bundles, queues,
ALTER LOCALITY GROUP, identitySKIP RANGE/START COUNTER WITH/ALTER IDENTITY,PLACEMENT KEY,AUTO_INCREMENT,ON UPDATE, table synonyms,ALTER INDEX ADD/DROP STORED COLUMN.DROP CHANGE STREAM/DROP LOCALITY GROUPuseDropStatement;RENAME TABLEaccepts further pairs.Reference syntax also implemented
CREATE LOCALITY GROUP(FEATURE_CREATE_LOCALITY_GROUP) and theCREATE TABLEttl_clause. The corpus generator now enables+TTL,+CREATE_LOCALITY_GROUP, turning 8 former backlog statements into golden cases. Two backlog entries missing a semicolon in the docs are reclassified astypo. Regeneration rewrites the feature line in the generated.testfiles and drops the empty{}sidecars.Note
ParseStatementand friends (nil features = everything enabled) now accept Spanner syntax by default.Tests
TestSpannerOnlySyntax: every backlog statement parses withSPANNER_DDLand fails without it (ids checked against the SQL hash to catch format drift)parser/testdata/extensions/spanner/, run byTestParserasextensions/..., including feature-off errorsSPANNER_DDL(~2M execs, no crashes)go test ./... -timeout 60sand-check-parseclean🤖 Generated with Claude Code
https://claude.ai/code/session_01FTpNRheE3PdSX5XftfH7Nq
Generated by Claude Code