crate / crate

CrateDB is a distributed and scalable SQL database for storing and analyzing massive amounts of data in near real-time, even with complex queries. It is PostgreSQL-compatible, and based on Lucene.
https://cratedb.com/product
Apache License 2.0
4.07k stars 558 forks source link

Nested arrays in `WHERE` clause causes ClassCastExceptions #16299

Closed jeeminso closed 2 weeks ago

jeeminso commented 2 months ago

CrateDB version

latest master

CrateDB setup information

No response

Problem description

Please see the steps to reproduce

Steps to Reproduce

cr> create table a (a int[][]);
CREATE OK, 1 row affected (0.610 sec)
cr> insert into a values ([ [1],[2],[] ]);
INSERT OK, 1 row affected (0.048 sec)

cr> select * from a where [1] != any(a);
ClassCastException[class java.util.ArrayList cannot be cast to class java.lang.Number (java.util.ArrayList and java.lang.Number are in module java.base of loader 'bootstrap')]

Actual Result

ClassCastException[class java.util.ArrayList cannot be cast to class java.lang.Number (java.util.ArrayList and java.lang.Number are in module java.base of loader 'bootstrap')]

Expected Result

1 row returned

jeeminso commented 2 months ago

Similarly,

cr> select * from t where a != any [[1]];
ClassCastException[class java.util.ArrayList cannot be cast to class java.lang.Number (java.util.ArrayList and java.lang.Number are in module java.base of loader 'bootstrap')]

where a is an 1D array.

jeeminso commented 2 months ago

Not just NeqAny operator, basically LuceneQueryBuilder cannot handle nested arrays,

cr> select * from a where a != [[1], [2], []];
ClassCastException[class java.util.ArrayList cannot be cast to class java.lang.Number (java.util.ArrayList and java.lang.Number are in module java.base of loader 'bootstrap')]
jeeminso commented 2 weeks ago

I have tested current existing operators against nested arrays and they either throw UnsupportedFunctionException or return. Closing.