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

Benchao Li commented on CALCITE-6142:
-------------------------------------

{{SqlDialect}} is now mainly used for rel2sql, not sql2rel. To config the 
Parser behavior, you can directly configure {{SqlParser.Config}}, e.g. 
{{withQuoting(Quoting.DOUBLE_QUOTE_BACKSLASH)}}.

> Double quote does not work as literal quote string in sql parsing
> -----------------------------------------------------------------
>
>                 Key: CALCITE-6142
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6142
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.32.0, 1.36.0
>            Reporter: peng wu
>            Priority: Critical
>
> When tried to parse spark sql express where double quote(") as literal quote 
> string, calcite sql parser threw an exception: 
>     org.apache.calcite.sql.parser.impl.ParseException: Encountered "\"" at 
> line 1, column 26.
>     Was expecting one of:
>     "ABS" ...
>     "ARRAY" ...    "AVG" ...
> The literal quote string is specified in sql parser config.
> Here is my test case:
> {code:java}
> public static void main(String[] args) throws Exception {
>     String sqlQuery = "case  when `Area` in (   \"Region1\", \"Region2\", 
> \"Region3\"  ) then `Sales`  else null end";
>     //create spark dialect
>     SqlDialect.Context context = SqlDialect.EMPTY_CONTEXT
>             .withDatabaseProduct(SqlDialect.DatabaseProduct.SPARK)
>             .withUnquotedCasing(Casing.UNCHANGED)
>             .withNullCollation(NullCollation.LOW)
>             .withIdentifierQuoteString("`")
>             .withLiteralQuoteString("\"");
>     SqlDialect sparkDialect = new SparkSqlDialect(context);
>     SqlParser.Config config = 
> sparkDialect.configureParser(SqlParser.config());
>     // Create an SQL parser
>     SqlParser parser = SqlParser.create(sqlQuery, config);
>     // Parse the query into an AST. Here the exception occurred
>     SqlNode sqlNode = parser.parseExpression();
>   } {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to