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

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

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: mongodb-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;
      

      Mongo Adapter Exception

      select * from "mongo"."col"
      where _MAP['foo'] in ('1', '2') and true;

      java.lang.AssertionError: cannot translate OR(=(ITEM($0, 'foo'), '1'),
      =(ITEM($0, 'foo'), '2'))
      at org.apache.calcite.adapter.mongodb.MongoFilter$
      Translator.translateMatch2(MongoFilter.java:181)
      at org.apache.calcite.adapter.mongodb.MongoFilter$
      Translator.translateAnd(MongoFilter.java:116)
      at org.apache.calcite.adapter.mongodb.MongoFilter$
      Translator.translateOr(MongoFilter.java:98)
      at org.apache.calcite.adapter.mongodb.MongoFilter$
      Translator.translateMatch(MongoFilter.java:91)
      at org.apache.calcite.adapter.mongodb.MongoFilter$
      Translator.access$000(MongoFilter.java:77)
      at org.apache.calcite.adapter.mongodb.MongoFilter.implement(
      MongoFilter.java:72)
      at org.apache.calcite.adapter.mongodb.MongoRel$Implementor.
      visitChild(MongoRel.java:51)
      at org.apache.calcite.adapter.mongodb.MongoToEnumerableConverter.
      implement(MongoToEnumerableConverter.java:84)
      at org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.
      implementRoot(EnumerableRelImplementor.java:103)
      at org.apache.calcite.adapter.enumerable.EnumerableInterpretable.
      toBindable(EnumerableInterpretable.java:92)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mmior Michael Mior
                Reporter:
                sereda Andrei Sereda
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: