xiedeyantu commented on code in PR #4730:
URL: https://github.com/apache/calcite/pull/4730#discussion_r2700314334
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -2180,6 +2190,65 @@ 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) {
+ return Functions.compareLists((List<?>) b0, (List<?>) b1) == 0;
+ }
+ if (b0 instanceof Map && b1 instanceof Map) {
+ return Functions.compareMaps((Map<?, ?>) b0, (Map<?, ?>) b1) == 0;
+ }
+ if (b0 instanceof Object[] && b1 instanceof Object[]) {
+ return Functions.compareObjectArrays((Object[]) b0, (Object[]) b1) == 0;
+ }
+ 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;
+ }
+
+ /** Compares two nullable objects recursively if they are collections.
+ * Nulls are treated as larger than non-null values. */
+ private static int compareNullable(@Nullable Object b0, @Nullable Object b1,
String op) {
Review Comment:
Sorry, I forgot to mention that this op is used to record the type of
comparison operation for user-friendly display in error messages. If there are
no issues, I will add it to the javadoc.
--
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]