Skip to content

[CALCITE-7566] Support BigQuery-style bare bracket array literals#4975

Draft
takaaki7 wants to merge 1 commit into
apache:mainfrom
takaaki7:dev-0531-144845
Draft

[CALCITE-7566] Support BigQuery-style bare bracket array literals#4975
takaaki7 wants to merge 1 commit into
apache:mainfrom
takaaki7:dev-0531-144845

Conversation

@takaaki7
Copy link
Copy Markdown

Summary

  • Adds support for BigQuery-style array literals written without the ARRAY keyword, e.g. SELECT [1, 2, 3], when conformance is BIG_QUERY (also BABEL, LENIENT).
  • Introduces SqlConformance#allowBareBracketArrayLiteral() and gates a new alternative in the JavaCC ArrayConstructor production with it. The new alternative emits the same ARRAY_VALUE_CONSTRUCTOR call used by ARRAY[...], so validation, type derivation, and unparse paths require no other changes.
  • Fixes CALCITE-7566.

Test plan

  • New SqlParserTest#testBareBracketArrayLiteral covers [1, 2, 3], empty [], nested [[1, 2], [3, 4]], subscript [10, 20, 30][1], and SELECT [1, 2, 3] under BIG_QUERY; also asserts BABEL/LENIENT accept and DEFAULT/STRICT_2003 reject.
  • ./gradlew :core:test --tests CoreSqlParserTest --tests SqlUnParserTest — 991 passed, 0 failed (9 pre-existing skips).
  • JavaCC reports no new choice conflicts (the two pre-existing warnings near lines 1975 and 3703 are unchanged).

🤖 Generated with Claude Code

BigQuery accepts array literals written without the ARRAY keyword,
e.g. SELECT [1, 2, 3]. Calcite's parser previously rejected this form
with `Encountered "[" at line 1, column 8` even under
SqlConformanceEnum.BIG_QUERY.

Introduce SqlConformance#allowBareBracketArrayLiteral() (true for
BIG_QUERY, BABEL, LENIENT) and add a conformance-gated alternative in
the JavaCC ArrayConstructor production that consumes `[ ... ]` and
emits the same ARRAY_VALUE_CONSTRUCTOR call used by the existing
`ARRAY[...]` syntax, so validation, type derivation, and unparse paths
need no further change.
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant