You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Dan Cojocaru (Jira)" <ji...@apache.org> on 2020/06/23 04:30:00 UTC

[jira] [Comment Edited] (CALCITE-4080) Exception occurs when parsing quoted aliases for select columns

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

Dan Cojocaru edited comment on CALCITE-4080 at 6/23/20, 4:29 AM:
-----------------------------------------------------------------

MySQL documentation states otherwise. Please check this section : [https://dev.mysql.com/doc/refman/5.7/en/problems-with-alias.html] 

They provide this example :

"

_In the select list of a query, a quoted column alias can be specified using identifier or string quoting characters:_
  SELECT 1 AS `one`, 2 AS 'two';
 "

[~julianhyde] Thanks for looking over this issue in such a short time.

 


was (Author: dan.cojocaru):
MySQL documentation states otherwise. Please check this section : [https://dev.mysql.com/doc/refman/5.7/en/problems-with-alias.html] 

They provide this example :

"

_In the select list of a query, a quoted column alias can be specified using identifier or string quoting characters:_
  SELECT 1 AS `one`, 2 AS 'two';
 "

[~julianhyde] Thanks for looking over this issue is such a short time.

 

> Exception occurs when parsing quoted aliases for select columns
> ---------------------------------------------------------------
>
>                 Key: CALCITE-4080
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4080
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.23.0
>            Reporter: Dan Cojocaru
>            Priority: Major
>
> Exception occurs while parsing query with quoted alias for select columns. 
> {code:java}
> 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");
> {code}
> The following exception is thrown: 
> {code:java}
> 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> ...{code}
> If query is changed into :  
> {code:java}
> "SELECT 1 AS some_alias from dual"
> {code}
> the query is parsed correctly.
>  
> Quoted aliases ( e.g:  'some alias' ) {color:#172b4d}should be valid as well.{color}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)