[ 
https://issues.apache.org/jira/browse/CALCITE-4450?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Vova Vysotskyi updated CALCITE-4450:
------------------------------------
    Summary: ElasticSearch query with varchar literal projection fails with 
JsonParseException  (was: Query on ElasticSearch table that projects varchar 
literal fails with JsonParseException)

> ElasticSearch query with varchar literal projection fails with 
> JsonParseException
> ---------------------------------------------------------------------------------
>
>                 Key: CALCITE-4450
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4450
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.26.0
>            Reporter: Vova Vysotskyi
>            Assignee: Vova Vysotskyi
>            Priority: Major
>             Fix For: 1.27.0
>
>
> A query that contains varchar literals in projection fails for ElasticSearch 
> adapter. Simple test case to reproduce the issue:
> {code:java}
> @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");
>   }
> {code}
> Error:
> {noformat}
> 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)
> {noformat}
> 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to