[ 
https://issues.apache.org/jira/browse/CALCITE-7566?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated CALCITE-7566:
------------------------------------
    Labels: pull-request-available  (was: )

> Support BigQuery-style bare bracket array literals (e.g. [1, 2, 3]) under 
> BigQuery conformance
> ----------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7566
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7566
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.41.0
>            Reporter: tnakama
>            Priority: Minor
>              Labels: pull-request-available
>
>   
>  BigQuery supports a shorthand syntax for array literals using just square 
> brackets,
>  without the `ARRAY` keyword:
>  ```sql
>  SELECT [1, 2, 3] AS arr;
>  This is documented as equivalent to ARRAY<T>[...] / ARRAY[...] in BigQuery's 
> Standard SQL:
>  
> https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#array_literals
>  When parsing such queries with Calcite using fun=bigquery and/or 
> conformance=BIG_QUERY, the parser fails because it only recognises
>  ARRAY[...] / ARRAY(...) constructors.
>  Reproduction
>  SqlParser.Config config = SqlParser.config()
>      .withConformance(SqlConformanceEnum.BIG_QUERY)
>      .withLex(Lex.BIG_QUERY);
>  SqlParser.create("SELECT [1, 2, 3]", config).parseQuery();
>  // → SqlParseException: Encountered "[" at line 1, column 8
>  Whereas BigQuery accepts it natively:
>  $ bq query --use_legacy_sql=false 'SELECT [1, 2, 3] AS arr'
>  +-----------+
>  |    arr    |
>  +-----------+
>  | [1, 2, 3] |
>  +-----------+
>  Suggested implementation outline
>  In core/src/main/codegen/templates/Parser.jj, the array constructor rule 
> (around line 5252) currently requires the ARRAY keyword. Add a 
> conformance-gated alternative in AtomicRowExpression (or wherever expression 
> atoms are parsed) that, when getConformance().allowBareBracketArrayLiteral() 
> (new predicate on SqlConformance) is true, accepts LBRACKET ... RBRACKET and 
> emits the same ARRAY_VALUE_CONSTRUCTOR call.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to