mihaibudiu commented on code in PR #4730:
URL: https://github.com/apache/calcite/pull/4730#discussion_r2678176728


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -2180,6 +2189,144 @@ public static boolean neAny(Object b0, Object b1) {
     return !eqAny(b0, b1);
   }
 
+  private static boolean eqNullable(@Nullable Object b0, @Nullable Object b1) {
+    if (b0 == b1) {
+      return true;
+    }
+    if (b0 == null || b1 == null) {
+      return false;
+    }
+    if (b0 instanceof List && b1 instanceof List) {
+      final List<?> l0 = (List<?>) b0;
+      final List<?> l1 = (List<?>) b1;
+      if (l0.size() != l1.size()) {
+        return false;
+      }
+      for (int i = 0; i < l0.size(); i++) {
+        if (!eqNullable(l0.get(i), l1.get(i))) {
+          return false;
+        }
+      }
+      return true;
+    }
+    if (b0 instanceof Map && b1 instanceof Map) {
+      final Map<?, ?> m0 = (Map<?, ?>) b0;
+      final Map<?, ?> m1 = (Map<?, ?>) b1;
+      if (m0.size() != m1.size()) {
+        return false;
+      }
+      final Iterator<? extends Map.Entry<?, ?>> i0 = m0.entrySet().iterator();
+      final Iterator<? extends Map.Entry<?, ?>> i1 = m1.entrySet().iterator();
+      while (i0.hasNext() && i1.hasNext()) {
+        final Map.Entry<?, ?> e0 = i0.next();
+        final Map.Entry<?, ?> e1 = i1.next();
+        if (!eqNullable(e0.getKey(), e1.getKey())) {
+          return false;
+        }
+        if (!eqNullable(e0.getValue(), e1.getValue())) {
+          return false;
+        }
+      }
+      return true;
+    }
+    if (b0 instanceof Object[] && b1 instanceof Object[]) {
+      final Object[] a0 = (Object[]) b0;
+      final Object[] a1 = (Object[]) b1;
+      if (a0.length != a1.length) {
+        return false;
+      }
+      for (int i = 0; i < a0.length; i++) {
+        if (!eqNullable(a0[i], a1[i])) {
+          return false;
+        }
+      }
+      return true;
+    }
+    if (b0.getClass().equals(b1.getClass())) {
+      if (b0 instanceof BigDecimal) {
+        return eq((BigDecimal) b0, (BigDecimal) b1);
+      }
+      return b0.equals(b1);
+    }
+    if (b0 instanceof Number && b1 instanceof Number) {
+      return eq(toBigDecimal((Number) b0), toBigDecimal((Number) b1));
+    }
+    return false;
+  }
+
+  private static int compareNullable(@Nullable Object b0, @Nullable Object b1, 
String op) {

Review Comment:
   I think you have to define what does it mean for a Map to be larger than 
another one.



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