[ 
https://issues.apache.org/jira/browse/CALCITE-5242?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17597775#comment-17597775
 ] 

Jianhui Dong commented on CALCITE-5242:
---------------------------------------

Thanks for your response, [~libenchao].

I tried `select row(map['1', 'he'])` and failed at parse phase with Calcite 
v1.26 as following: 

 
{code:java}
@Test
public void testRowAndMap() throws SqlParseException {
    String dml = "select row(map['1', 'he'])";
    final SqlParser.Config configBuilder =
            SqlParser.config()
                    .withParserFactory(SqlParserImpl.FACTORY)
                    .withQuoting(Quoting.DOUBLE_QUOTE)
                    .withUnquotedCasing(Casing.TO_UPPER)
                    .withQuotedCasing(Casing.UNCHANGED)
                    .withConformance(SqlConformance.DEFAULT);
    UnaryOperator<SqlParser.Config> transform =  UnaryOperator.identity();
    Config config = transform.apply(configBuilder);
    SqlParser sqlParser = SqlParser.create(new StringReader(dml), config);
    SqlNode sqlNode = sqlParser.parseStmt();
    System.out.println(sqlNode);
} {code}
Could u give me an example how you ran the case successfully?

 

> it will throw {{Map requires an even number of arguments}} when validating.

does this mean the parse phase will not throw an exception as above 
mentioned?(Encountered "[" at line 1, column 16)

> SQL query of row function call with nested map cannot be parsed
> ---------------------------------------------------------------
>
>                 Key: CALCITE-5242
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5242
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Jianhui Dong
>            Priority: Major
>         Attachments: image-2022-08-23-12-12-42-044.png
>
>
> I am not sure if this is a bug, calcite can not parse
> {code:java}
> select row(map['1']) FROM tableA
> {code}
> correctly, it would throw an exception as follows:
> {code:java}
> org.apache.calcite.sql.parser.SqlParseException: Encountered "[" at line 1, 
> column 16.
> Was expecting one of:
>     ")" ...
>     "," ...
> {code}
> However, I had a parser that extended Parser.jj with custom DDL, and it could 
> parse this DML normally.
> {code:java}
> @Test
> public void testSelectCase() throws Exception {
>     String dml = "select row(map['1']) FROM tableA";
>     parse(XflowSqlParserImpl.FACTORY, dml);
>     parse(SqlParserImpl.FACTORY, dml);
> }
> private void parse(SqlParserImplFactory factory, String dml) throws 
> SqlParseException {
>     final SqlParser.Config configBuilder =
>             SqlParser.config()
>                     .withParserFactory(factory)
>                     .withQuoting(Quoting.DOUBLE_QUOTE)
>                     .withUnquotedCasing(Casing.TO_UPPER)
>                     .withQuotedCasing(Casing.UNCHANGED)
>                     .withConformance(SqlConformance.DEFAULT);
>     UnaryOperator<SqlParser.Config> transform =  UnaryOperator.identity();
>     Config config = transform.apply(configBuilder);
>     SqlParser sqlParser = SqlParser.create(new StringReader(dml), config);
>     SqlNode sqlNode = sqlParser.parseStmt();
>     System.out.println(sqlNode);
> } {code}



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

Reply via email to