[ https://issues.apache.org/jira/browse/CALCITE-6142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17791874#comment-17791874 ]
Benchao Li commented on CALCITE-6142: ------------------------------------- I'm not an expert of parser, so I'm not sure why this restriction exists either. I agree with you that it would be nice to make it more flexible if possible. > 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)