Skip to content

sql/parser: require parens around resource group options#170976

Draft
rafiss wants to merge 1 commit into
cockroachdb:masterfrom
rafiss:cleanup-rg-with
Draft

sql/parser: require parens around resource group options#170976
rafiss wants to merge 1 commit into
cockroachdb:masterfrom
rafiss:cleanup-rg-with

Conversation

@rafiss
Copy link
Copy Markdown
Collaborator

@rafiss rafiss commented May 27, 2026

The grammar for with_resource_group_options previously accepted both WITH <opt> = <val>, ... and WITH (<opt> = <val>, ...).

Because BUCKET_COUNT is in the lexer's WITH_LA lookahead set, supporting the unparenthesized form required four grammar alternatives (the WITH and WITH_LA variants of each), and the generated BNF surfaced this as duplicate 'WITH' ... lines in stmt_block.bnf.

PR #170894 made the Format methods always emit the parenthesized form, so the unparenthesized grammar paths are no longer needed for the parse/format round-trip. Drop them and require parentheses, matching CRDB convention for arbitrary KV-style option lists (CREATE TABLE storage params, BACKUP ... WITH OPTIONS (...), etc.).

Resolves: #170788

Release note: None

The grammar for `with_resource_group_options` previously accepted
both `WITH <opt> = <val>, ...` and `WITH (<opt> = <val>, ...)`.

Because `BUCKET_COUNT` is in the lexer's `WITH_LA` lookahead set,
supporting the unparenthesized form required four grammar
alternatives (the `WITH` and `WITH_LA` variants of each), and the
generated BNF surfaced this as duplicate `'WITH' ...` lines in
`stmt_block.bnf`.

PR cockroachdb#170894 made the `Format` methods always emit the parenthesized form,
so the unparenthesized grammar paths are no longer needed for the
parse/format round-trip. Drop them and require parentheses, matching
CRDB convention for arbitrary KV-style option lists (`CREATE TABLE`
storage params, `BACKUP ... WITH OPTIONS (...)`, etc.).

Resolves: cockroachdb#170788

Release note: None
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented May 27, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@stevendanna
Copy link
Copy Markdown
Collaborator

Seems reasonable to me. I originally tried to make the non-parens syntax work to match the outcome brief. But I think consistency with other syntax is more reasonable.

Thoughts on whether we should be using this arbitrary option list as opposed to making Weight_CPU and friends keywords?

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.

sql/tests: TestRandomSyntaxGeneration failed

3 participants