rubenada commented on code in PR #5370:
URL: https://github.com/apache/calcite/pull/5370#discussion_r4457913906


##########
core/src/main/java/org/apache/calcite/adapter/enumerable/PhysTypeImpl.java:
##########
@@ -544,6 +530,36 @@ private Expression generateComparator(RelCollation 
collation,
     });
   }
 
+  private static boolean isComposite(RelDataType type) {
+    return type.isStruct() || type.getComponentType() != null;
+  }
+
+  /** ROW and ARRAY sort keys (including SEARCH columns) are not Comparable.
+   * Use the same element-wise comparator as the single-key sort path. */
+  private static Expression generateComparison(RelDataType type, String method,
+      Expression left, Expression right, @Nullable Expression collator) {
+    if (isComposite(type)) {
+      final Expression comparison =
+          Expressions.call(
+              Expressions.call(BuiltInMethod.NULLS_COMPARATOR.method,
+                  Expressions.constant(method.equals("compareNullsFirst")),
+                  Expressions.constant(false)),
+              BuiltInMethod.COMPARATOR_COMPARE.method, left, right);
+      if (method.equals("compareNullsLastForMergeJoin")) {
+        // Preserve the merge join's special signal for two null keys.

Review Comment:
   what's this "merge join's special signal for two null keys"



-- 
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]

Reply via email to