Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5242

SQL query of row function call with nested map cannot be parsed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None

    Description

      I am not sure if this is a bug, calcite can not parse

      select row(map['1']) FROM tableA
      

      correctly, it would throw an exception as follows:

      org.apache.calcite.sql.parser.SqlParseException: Encountered "[" at line 1, column 16.
      Was expecting one of:
          ")" ...
          "," ...
      

      However, I had a parser that extended Parser.jj with custom DDL, and it could parse this DML normally.

      @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);
      } 

      Attachments

        1. image-2022-08-23-12-12-42-044.png
          222 kB
          Jianhui Dong

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lam167 Jianhui Dong
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: