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

Allow character literals as column aliases, if SqlConformance.allowCharLiteralAlias()

    XMLWordPrintableJSON

Details

    Description

      Exception occurs while parsing query with quoted alias for select columns. 

      final FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.configBuilder().setLex(Lex.MYSQL)
      .setConformance(SqlConformanceEnum.MYSQL_5).build())
      .programs(Programs.ofRules(Programs.RULE_SET))
      .build(); 
      
      Planner p = Frameworks.getPlanner(config); 
      
      SqlNode n = p.parse("SELECT 1 AS 'some alias' from dual");
      
      

      The following exception is thrown: 

      org.apache.calcite.sql.parser.SqlParseException: Encountered "\'some alias\'" at line 1, column 13.
      Was expecting one of:
          <BRACKET_QUOTED_IDENTIFIER> ...
          <QUOTED_IDENTIFIER> ...
          <BACK_QUOTED_IDENTIFIER> ...
          <IDENTIFIER> ...
          <UNICODE_QUOTED_IDENTIFIER> ...

      If query is changed into :  

      "SELECT 1 AS some_alias from dual"
      

      the query is parsed correctly.

       

      Quoted aliases ( e.g:  'some alias' ) should be valid as well.

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              dan.cojocaru Dan Cojocaru
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m