I think maybe BigQuery Lex is what you need. Try
```
SqlParser.Config config = sparkDialect.configureParser(SqlParser.config())
        .withLex(Lex.BIG_QUERY);
```

hongyu


On Tue, Nov 28, 2023 at 6:49 PM 武鹏 <pen...@guandata.com> wrote:

> Hi all,
> I tried our SQL parser on version 1.32.0 and 1.36.0.
> I used double quote(") as literal quote string in my sql expression, and
> set it on my parser config, but it threw a sql parse exception:
> org.apache.calcite.sql.parser.impl.ParseException: Encountered "\"" at
> line 1, column 26.
>  Was expecting one of:
>  "ABS" ...
>  "ARRAY" ...
>  "AVG" ...
> I am not sure if this is bug, because double quote for literal string is
> not a rare case.
> Here is the my test case:
> 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();
> }
> Wish to get your reply.
> Thanks,
> Peng
>

Reply via email to