You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vova Vysotskyi (Jira)" <ji...@apache.org> on 2020/12/30 22:21:00 UTC

[jira] [Created] (CALCITE-4450) Query on ElasticSearch table that projects varchar literal fails with JsonParseException

Vova Vysotskyi created CALCITE-4450:
---------------------------------------

             Summary: Query on ElasticSearch table that projects varchar literal 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


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)