rubenada commented on code in PR #5393:
URL: https://github.com/apache/calcite/pull/5393#discussion_r4492056064
##########
core/src/test/java/org/apache/calcite/test/SqlFunctionsTest.java:
##########
@@ -1004,6 +1004,21 @@ private void checkCeil(int x, int y, int result) {
assertThat(Utilities.compare(empty, empty), is(0));
}
+ /** Composite null keys compare equally for sorting, but must not match in a
merge join. */
+ @Test void testCompareCompositeNullKeys() {
+ final Object key = new Object[]{1, null};
+ assertThat(Utilities.compareCompositeNullsFirst(null, null), is(0));
+ assertThat(Utilities.compareCompositeNullsLast(null, null), is(0));
+ assertThat(Utilities.compareCompositeNullsLastForMergeJoin(null, key),
is(1));
+ assertThat(Utilities.compareCompositeNullsLastForMergeJoin(key, null),
is(-1));
+ assertThat(Utilities.compareCompositeNullsLastForMergeJoin(key, new
Object[]{1, null}), is(0));
Review Comment:
Is this intended? IIUC merge join will match ROW(1, NULL) with ROW(1, NULL),
while SQL says ROW(1, NULL) = ROW(1, NULL) is UNKNOWN, is this not a bug on the
Join algorithm? Is this consistent with Calcite's HashJoin, or PostgreSQL join
behavior?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]