[CALCITE-7566] Support BigQuery-style bare bracket array literals#4975
[CALCITE-7566] Support BigQuery-style bare bracket array literals#4975takaaki7 wants to merge 1 commit into
Conversation
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.
|
| <LBRACKET> // TODO: do trigraph as well ??( ??) | ||
| // BigQuery bare bracket array literal "[e0, e1, ..., eN]" | ||
| LOOKAHEAD({ this.conformance.allowBareBracketArrayLiteral() }) | ||
| <LBRACKET> { s = span(); } |
There was a problem hiding this comment.
you can handle the empty argument list similar to the spark array constructor, and then the validator won't reject [] anymore. That is rather ugly, it's true, maybe we should fix the validator instead.
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@calcite.apache.org list. Thank you for your contributions. |



Summary
ARRAYkeyword, e.g.SELECT [1, 2, 3], when conformance isBIG_QUERY(alsoBABEL,LENIENT).SqlConformance#allowBareBracketArrayLiteral()and gates a new alternative in the JavaCCArrayConstructorproduction with it. The new alternative emits the sameARRAY_VALUE_CONSTRUCTORcall used byARRAY[...], so validation, type derivation, and unparse paths require no other changes.Test plan
SqlParserTest#testBareBracketArrayLiteralcovers[1, 2, 3], empty[], nested[[1, 2], [3, 4]], subscript[10, 20, 30][1], andSELECT [1, 2, 3]underBIG_QUERY; also assertsBABEL/LENIENTaccept andDEFAULT/STRICT_2003reject../gradlew :core:test --tests CoreSqlParserTest --tests SqlUnParserTest— 991 passed, 0 failed (9 pre-existing skips).🤖 Generated with Claude Code