Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2331

Evaluation of predicate "(A or B) and C" fails for Elasticsearch adapter

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.17.0
    • Component/s: elasticsearch-adapter
    • Labels:
      None

      Description

      Queries that are working

      select count(*) from "elastic" where _MAP['foo'] in ('1') and true;
      select count(*) from "elastic" where _MAP['foo'] ='1' and true;
      select count(*) from "elastic" where _MAP['foo'] in ('1', '2');
      

      Queries that are failing

      select count(*) from "elastic" where _MAP['foo'] in ('1', '2') and true;
      select count(*) from "elastic" where true and _MAP['foo'] in ('1', '2');
      select count(*) from "elastic" where (_MAP['foo'] ='1' or _MAP['foo'] = '2') and true;
      

      Elastic Adapter Exception

      java.lang.AssertionError: cannot translate OR(=(ITEM($0, 'foo'), '1'),
      =(ITEM($0, 'foo'), '2'))
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter$
      Translator.translateMatch2(ElasticsearchFilter.java:234)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter$
      Translator.translateAnd(ElasticsearchFilter.java:158)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter$
      Translator.translateOr(ElasticsearchFilter.java:115)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter$
      Translator.translateMatch(ElasticsearchFilter.java:101)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter$
      Translator.access$000(ElasticsearchFilter.java:87)
      at org.apache.calcite.adapter.elasticsearch.
      ElasticsearchFilter.implement(ElasticsearchFilter.java:80)
      at org.apache.calcite.adapter.elasticsearch.
      ElasticsearchRel$Implementor.visitChild(ElasticsearchRel.java:53)
      at org.apache.calcite.adapter.elasticsearch.
      ElasticsearchToEnumerableConverter.implement(ElasticsearchToEnumerableConve
      rter.java:71)
      at org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.
      visitChild(EnumerableRelImplementor.java:98)
      at org.apache.calcite.adapter.enumerable.
      EnumerableAggregate.implement(EnumerableAggregate.java:106)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michaelmior Michael Mior
                Reporter:
                asereda Andrei Sereda
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: