You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ian Bertolacci (Jira)" <ji...@apache.org> on 2022/09/09 16:28:00 UTC
[jira] [Closed] (CALCITE-5273) RelToSqlConverter allows unparsing of invalid CASE expression
[ https://issues.apache.org/jira/browse/CALCITE-5273?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ian Bertolacci closed CALCITE-5273.
-----------------------------------
Resolution: Won't Fix
> RelToSqlConverter allows unparsing of invalid CASE expression
> -------------------------------------------------------------
>
> Key: CALCITE-5273
> URL: https://issues.apache.org/jira/browse/CALCITE-5273
> Project: Calcite
> Issue Type: Bug
> Reporter: Ian Bertolacci
> Priority: Minor
>
> RelToSqlConverter will unparse the invalid† CASE expression {{`CASE ELSE 1 END`}} (which can be constructed using either RelBuilder or RexBuilder, see CALCITE-5272).
> († Or at least and expression which Calcite then cannot parse.)
> Given this RelNode tree with invalid case statements
> {code}
> 1:LogicalProject($f0=[CASE(1)], $f1=[CASE(1:BIGINT)])
> 0:LogicalValues(tuples=[[{ 0 }]])
> {code}
> Unparsing with RelToSqlConverter using MysqlSqlDialect.DEFAULT‡ gives the Sql:
> {code}
> SELECT CASE ELSE 1 END AS `$f0`, CASE ELSE 1 END AS `$f1`
> {code}
> Running that sql back through the parser using Lex.MYSQL‡ and SqlConformanceEnum.MYSQL_5‡ throws the exception:
> {code}
> Incorrect syntax near the keyword 'CASE' at line 1, column 8.
> Was expecting one of:
> "ALL" ...
> "CURSOR" ...
> "DISTINCT" ...
> ...
> org.apache.calcite.sql.parser.SqlParseException: Incorrect syntax near the keyword 'CASE' at line 1, column 8.
> Was expecting one of:
> "ALL" ...
> "CURSOR" ...
> "DISTINCT" ...
> ...
> at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:389)
> at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:153)
> at org.apache.calcite.sql.parser.SqlParser.handleException(SqlParser.java:145)
> at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:160)
> at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:185)
> at org.apache.calcite.prepare.PlannerImpl.parse(PlannerImpl.java:214)
> at org.apache.calcite.tools.Planner.parse(Planner.java:50)
> ..
> Caused by: org.apache.calcite.sql.parser.impl.ParseException: Incorrect syntax near the keyword 'CASE' at line 1, column 8.
> Was expecting one of:
> "ALL" ...
> "CURSOR" ...
> "DISTINCT" ...
> ...
> at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:349)
> ... 59 more
> {code}
> ‡ I don't believe the specific dialect/lex/conformance parameters affect the outcome.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)