Skip to content

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

Merged
trunk-io[bot] merged 1 commit into
cockroachdb:masterfrom
rafiss:cleanup-rg-with
May 27, 2026
Merged

sql/parser: require parens around resource group options#170976
trunk-io[bot] merged 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

@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented May 27, 2026

😎 Merged successfully - details.

@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?

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
@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented May 27, 2026

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

I think we should keep it as an arbitrary option list, similar to what we do for table storage parameters. The option name validation can still happen at planning time. When we've tried making option names keywords, like for BUCKET_COUNT or some BACKUP options, it generally just adds overhead and causes headaches without much benefit.

@rafiss rafiss force-pushed the cleanup-rg-with branch from 9aece20 to 61c0d5e Compare May 27, 2026 17:21
@rafiss rafiss marked this pull request as ready for review May 27, 2026 17:21
@rafiss rafiss requested a review from a team as a code owner May 27, 2026 17:21
@rafiss rafiss requested review from michae2 and stevendanna and removed request for a team May 27, 2026 17:21
@trunk-io trunk-io Bot merged commit e05551a into cockroachdb:master May 27, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql/tests: TestRandomSyntaxGeneration failed

3 participants