feat(plsql): fill CREATE TABLE grammar gaps against Oracle 19c spec#66
Merged
feat(plsql): fill CREATE TABLE grammar gaps against Oracle 19c spec#66
Conversation
Systematic pass comparing the PL/SQL grammar against the Oracle 19c
CREATE TABLE reference. Directly unblocks the reported failure on
CREATE TABLE ... PARTITION BY RANGE ... INTERVAL (NUMTODSINTERVAL(...))
(... VALUES LESS THAN (DATE '...'))
Tier 1 — partition value clauses accept full expressions:
- range_values_clause: literal-only -> (expression | MAXVALUE)
- list_values_clause: broadened to (expression | NULL) and tuple form
for multi-column LIST partitioning; kept DEFAULT
Tier 2 — structural keywords and blockchain flexibility:
- CREATE TABLE IF NOT EXISTS
- list_partitions / composite_list_partitions / subpartition_by_list:
accept multi-column partition keys and optional AUTOMATIC
- blockchain_table_clauses: NO DROP / NO DELETE clauses now optional
- blockchain_row_retention_clause: accept 'DAYS IDLE' form
- blockchain_hash_and_data_format_clause: accept arbitrary CHAR_STRING
or DELIMITED_ID for hash algorithm and version (removed the
hardcoded SHA2_512_Q / V1_Q lexer tokens)
Tier 3 — missing top-level partition strategies (12.2+/19c):
- PARTITION BY CONSISTENT HASH (... ) PARTITIONS AUTO [SUBPARTITION ...]
- PARTITION BY PARTITIONSET {RANGE|LIST} with range_partitionset_desc
and list_partitionset_desc
Tier 4 — completeness:
- range_subpartition_desc / list_subpartition_desc / individual_hash_subparts:
accept optional read_only_clause and indexing_clause
- column_definition: accept optional annotations_clause (Oracle 23c)
New regression fixture plsql/examples/create_table_grammar_gaps.sql
covers every scenario above. Full test suite (go test ./...) is green.
There was a problem hiding this comment.
Pull request overview
Updates the Oracle PL/SQL ANTLR grammar to better match Oracle 19c CREATE TABLE syntax, primarily expanding partitioning support (including expression-valued partition bounds) and adding missing partitioning variants that previously failed to parse (e.g., the BYT-9302 interval/range case).
Changes:
- Broadened RANGE/LIST partition value clauses to accept full expressions and added additional partitioning strategies (CONSISTENT HASH, PARTITIONSET).
- Added
CREATE TABLE IF NOT EXISTS, enhanced LIST partition key support (multi-column +AUTOMATIC), and loosened blockchain table clause requirements. - Added a new SQL fixture file to exercise the newly-supported grammar forms via the existing PL/SQL parser test harness.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| plsql/PlSqlParser.g4 | Core grammar updates for CREATE TABLE partitioning, blockchain clauses, and column annotations. |
| plsql/PlSqlLexer.g4 | Adds PARTITIONSET token; removes hardcoded blockchain hash/version tokens. |
| plsql/examples/create_table_grammar_gaps.sql | New regression fixtures covering the newly supported CREATE TABLE forms. |
| plsql/plsqlparser_listener.go | Regenerated listener interface for new grammar productions. |
| plsql/plsqlparser_base_listener.go | Regenerated base listener stubs for new grammar productions. |
| plsql/plsqlparser_visitor.go | Regenerated visitor interface for new grammar productions. |
| plsql/plsqlparser_base_visitor.go | Regenerated base visitor stubs for new grammar productions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review feedback: the parenthesized-tuple alternative in list_partition_value was unreachable because expression -> atom already matches LEFT_PAREN expressions RIGHT_PAREN with identical semantics. Remove the dedicated tuple layer and rely on expression for tuple form in multi-column LIST partitioning — same parse coverage with simpler AST shape. Comments on range_partition_value and list_partition_value explain why their inner alternatives stay (clarity of intended terminals).
rebelice
approved these changes
Apr 17, 2026
h3n4l
added a commit
to bytebase/bytebase
that referenced
this pull request
Apr 17, 2026
Bump github.com/bytebase/parser to pick up bytebase/parser#66, which closes a batch of CREATE TABLE grammar gaps against the Oracle 19c spec. Directly unblocks BYT-9302: PARTITION BY RANGE ... INTERVAL (NUMTODSINTERVAL(...)) (... VALUES LESS THAN (DATE '...')) now parses. Add the reported fixture as a regression test in TestPLSQLParser. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merged
3 tasks
h3n4l
added a commit
to bytebase/bytebase
that referenced
this pull request
Apr 17, 2026
Bump github.com/bytebase/parser to pick up bytebase/parser#66, which closes a batch of CREATE TABLE grammar gaps against the Oracle 19c spec. Directly unblocks BYT-9302: PARTITION BY RANGE ... INTERVAL (NUMTODSINTERVAL(...)) (... VALUES LESS THAN (DATE '...')) now parses. Add the reported fixture as a regression test in TestPLSQLParser. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
h3n4l
added a commit
to bytebase/bytebase
that referenced
this pull request
Apr 17, 2026
…#20042) Bump github.com/bytebase/parser to pick up bytebase/parser#66, which closes a batch of CREATE TABLE grammar gaps against the Oracle 19c spec. Directly unblocks BYT-9302: PARTITION BY RANGE ... INTERVAL (NUMTODSINTERVAL(...)) (... VALUES LESS THAN (DATE '...')) now parses. Add the reported fixture as a regression test in TestPLSQLParser. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Systematic pass against Oracle 19c CREATE TABLE reference to close gaps in
plsql/PlSqlParser.g4. Directly unblocks BYT-9302 —PARTITION BY RANGE (...) INTERVAL (NUMTODSINTERVAL(...)) (PARTITION p0 VALUES LESS THAN (DATE '2026-01-01'))failed to parse.Changes are grouped into four tiers by priority and scope.
Tier 1 — partition value clauses accept full expressions (root cause of BYT-9302)
Oracle spec says
VALUES LESS THAN ( expr | MAXVALUE )andVALUES ( { expr | NULL } | DEFAULT ). The grammar previously restricted both to the narrowliteralrule (CHAR_STRING | string_function | numeric | MAXVALUE), which excludedDATE '...',TIMESTAMP '...', arithmetic,NULL, and multi-column tuple form.range_values_clause→(expression | MAXVALUE)list_values_clause→(expression | NULL)plus tuple form((1,2),(3,4))for multi-column LISTTier 2 — structural keywords and blockchain flexibility
CREATE TABLE IF NOT EXISTSlist_partitions/composite_list_partitions/subpartition_by_list: accept multi-column partition keys and optionalAUTOMATICblockchain_table_clauses:NO DROP/NO DELETEclauses now optional (only the hash clause is required)blockchain_row_retention_clause: acceptDAYS IDLE(in addition toDAYS AFTER INSERT)blockchain_hash_and_data_format_clause: accept arbitraryCHAR_STRINGorDELIMITED_IDfor algorithm and version (removed the hardcodedSHA2_512_Q/V1_Qlexer tokens that forced a specific literal spelling)Tier 3 — missing top-level partition strategies (12.2+/19c)
PARTITION BY CONSISTENT HASH (...) PARTITIONS AUTO [SUBPARTITION BY {RANGE|LIST} (...) SUBPARTITIONS AUTO]PARTITION BY PARTITIONSET {RANGE|LIST} (...)withrange_partitionset_descandlist_partitionset_descPARTITIONSETlexer tokenTier 4 — completeness
range_subpartition_desc/list_subpartition_desc/individual_hash_subparts: accept optionalread_only_clauseandindexing_clausecolumn_definition: accept optionalannotations_clause(Oracle 23c)Test plan
make build(regenerates Go parser) — no new ANTLR warningsgo test ./plsql/...green (all pre-existing example SQL fixtures pass)go test ./...green across all 20 engine parsersplsql/examples/create_table_grammar_gaps.sqlcovers every scenario above and is exercised by the existingTestPLSQLParserharnessbytebase/bytebasevia a temporaryreplacedirective: the 11 previously failingParsePLSQLcases (DATE/TIMESTAMP range bounds, arithmetic bounds, NULL in LIST, multi-column LIST,AUTOMATIC,IF NOT EXISTS,CONSISTENT HASH,PARTITIONSET, blockchainDAYS IDLE) now all parse🤖 Generated with Claude Code