peng wu created CALCITE-6142:
--------------------------------
Summary: 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.36.0, 1.32.0
Environment: 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}
Reporter: peng wu
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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)