OSDir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RxNode (Filter) / Translator for various adapters (ES, Mongo, Geode etc.). Possible Bug ?


Looks like a bug. I don't know that code well, so I can't speculate
what might be the cause.

Can you log a JIRA case please? If you can provide a unit test (say, a
method to add to MongoAdapterIT) even better.

On Mon, May 28, 2018 at 2:47 PM, Andrei Sereda <andrei@xxxxxxxxx> wrote:
> Hello,
>
> Please correct me if my expectations are inaccurate about query predicates
> in Calcite.
>
> I think there is an issue in how expression translators work when AST is
> more complex (has more depth). Same code / logic is used across different
> adapters (Mongo / Geode / ES) so multiple data-sources might be affected.
>
> Examples
>
> 1. Works
>
> 0: jdbc:calcite:model=target/test-classes/mod> select count(*) from
> "elastic" where _MAP['foo'] in ('1') and true;
>
> 2. Works
> 0: jdbc:calcite:model=target/test-classes/mod> select count(*) from
> "elastic" where _MAP['foo'] ='1' and true;
>
> 3. Works
> 0: jdbc:calcite:model=target/test-classes/mod> select count(*) from
> "elastic" where _MAP['foo'] in ('1', '2');
>
>
> 4. Fails
>
> 0: jdbc:calcite:model=target/test-classes/mod> select count(*) from
> "elastic" where _MAP['foo'] in ('1', '2') and true;
>
>
> 5. Fails
>
> 0: jdbc:calcite:model=target/test-classes/mod> select count(*) from
> "elastic" where true and _MAP['foo'] in ('1', '2');
>
>
> 6. Fails
>
> 0: jdbc:calcite:model=target/test-classes/mod> select count(*) from
> "elastic" where (_MAP['foo'] ='1' or _MAP['foo'] = '2') and true;
>
>
>
> Exception Stack (Elastic Adapter)
>
>
> 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)
>
> Exception Stack (Mongo Adapter)
>
> 0: jdbc:calcite:model=target/test-classes/mod> 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)
>
>
>
> Anything I'm doing wrong ?
>
> Thanks,
> Andrei.