Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.26.0
-
None
Description
A query that contains varchar literals in projection fails for ElasticSearch adapter. Simple test case to reproduce the issue:
@Test void projectionStringLiteral() { CalciteAssert.that() .with(newConnectionFactory()) .query( String.format(Locale.ROOT, "select 'foo' as \"lit\"\n" + "from \"elastic\".\"%s\"", NAME)) .returns("lit=foo\n"); }
Error:
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('f' (code 102)): was expecting comma to separate Object entries at [Source: (String)"{"script_fields": {"lit":{"script": ""foo""}, "a":{"script": "params._source.a"}}}"; line: 1, column: 40] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1840)
The problem is that RexToElasticsearchTranslator.visitLiteral method do not escape literal quotes, and forms the following string: "lit":""foo"" that cannot be handled by jackson.
Attachments
Issue Links
- links to