Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.21.0
-
None
Description
Similar to CALCITE-3021.
Problem can be reproduced via:
select * from (values (1, ROW(1,1)), (2, ROW(2,2)), (3, ROW(1,1)), (4, ROW(2,2))) as t(id,struct) where t.struct = ROW(2,2);
which returns no results, instead of the expected (I have run the same query in PostgreSQL, and it returns this result):
+----+--------+ | ID | STRUCT | +----+--------+ | 2 | {2, 2} | | 4 | {2, 2} | +----+--------+
The issue is that the comparison is done via SqlFunctions#eq(Object b0, Object b1)
public static boolean eq(Object b0, Object b1) { return b0.equals(b1); }
And in this case we have two different Object[], with the same content, so they should be identified as equals (but they are not, based on Object#equals). Probably the simplest solution would be overloading the eq method for Object[] parameters:
public static boolean eq(Object[] b0, Object[] b1) { return Arrays.deepEquals(b0, b1); }
Attachments
Issue Links
- is related to
-
CALCITE-3021 Equality of nested ROWs returns false for identical values
- Closed
- links to