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

Babel parser should parse PostgreSQL table functions

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.18.0
    • Fix Version/s: None
    • Component/s: babel
    • Labels:
      None

      Description

      Code to reproduce the problem

      public static void main(String[] args) throws Exception {
          Config parserConfig = configBuilder().setConformance(SqlConformanceEnum.BABEL).setParserFactory(SqlBabelParserImpl.FACTORY).build();
          FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder().parserConfig(parserConfig).build();
      
          Planner planner = Frameworks.getPlanner(frameworkConfig);
          String pg = "select * from generate_series(1, 5)";
          planner.parse(pg);
      }
      

       

      Thrown exception

      Exception in thread "main" org.apache.calcite.sql.parser.SqlParseException: Encountered "( 1" at line 1, column 30.
      Was expecting one of:
          <EOF>
          "ORDER" ...
          "LIMIT" ...
          "OFFSET" ...
          "FETCH" ...
          "NATURAL" ...
          "JOIN" ...
          "INNER" ...
          "LEFT" ...
          "RIGHT" ...
          "FULL" ...
          "CROSS" ...
          "," ...
          "OUTER" ...
          "(" <IDENTIFIER> ...
          "(" <QUOTED_IDENTIFIER> ...
          "(" <BACK_QUOTED_IDENTIFIER> ...
          "(" <BRACKET_QUOTED_IDENTIFIER> ...
          "(" <UNICODE_QUOTED_IDENTIFIER> ...
          "MATCH_RECOGNIZE" ...
          "." ...
          "(" ...
          <IDENTIFIER> ...
          <QUOTED_IDENTIFIER> ...
          <BACK_QUOTED_IDENTIFIER> ...
          <BRACKET_QUOTED_IDENTIFIER> ...
          <UNICODE_QUOTED_IDENTIFIER> ...
          "TABLESAMPLE" ...
          "WHERE" ...
          "GROUP" ...
          "HAVING" ...
          "WINDOW" ...
          "UNION" ...
          "INTERSECT" ...
          "EXCEPT" ...
          "MINUS" ...
          
          at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.convertException(SqlBabelParserImpl.java:354)
          at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.normalizeException(SqlBabelParserImpl.java:142)
          at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:156)
          at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:181)
          at org.apache.calcite.prepare.PlannerImpl.parse(PlannerImpl.java:174)
          at org.apache.calcite.tools.Planner.parse(Planner.java:50)
          at com.lab.calcite.App2.main(App2.java:24)
      Caused by: org.apache.calcite.sql.parser.babel.ParseException: Encountered "( 1" at line 1, column 30.
      Was expecting one of:
          <EOF>
          "ORDER" ...
          "LIMIT" ...
          "OFFSET" ...
          "FETCH" ...
          "NATURAL" ...
          "JOIN" ...
          "INNER" ...
          "LEFT" ...
          "RIGHT" ...
          "FULL" ...
          "CROSS" ...
          "," ...
          "OUTER" ...
          "(" <IDENTIFIER> ...
          "(" <QUOTED_IDENTIFIER> ...
          "(" <BACK_QUOTED_IDENTIFIER> ...
          "(" <BRACKET_QUOTED_IDENTIFIER> ...
          "(" <UNICODE_QUOTED_IDENTIFIER> ...
          "MATCH_RECOGNIZE" ...
          "." ...
          "(" ...
          <IDENTIFIER> ...
          <QUOTED_IDENTIFIER> ...
          <BACK_QUOTED_IDENTIFIER> ...
          <BRACKET_QUOTED_IDENTIFIER> ...
          <UNICODE_QUOTED_IDENTIFIER> ...
          "TABLESAMPLE" ...
          "WHERE" ...
          "GROUP" ...
          "HAVING" ...
          "WINDOW" ...
          "UNION" ...
          "INTERSECT" ...
          "EXCEPT" ...
          "MINUS" ...
          
          at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.generateParseException(SqlBabelParserImpl.java:31191)
          at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.jj_consume_token(SqlBabelParserImpl.java:31008)
          at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.SqlStmtEof(SqlBabelParserImpl.java:877)
          at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.parseSqlStmtEof(SqlBabelParserImpl.java:198)
          at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:148)
          ... 4 more
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mgelbana Mohamed Mohsen
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: