danny0405 commented on a change in pull request #2019:
URL: https://github.com/apache/calcite/pull/2019#discussion_r441940857



##########
File path: core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
##########
@@ -1160,6 +1160,59 @@ public static boolean equalSansNullability(
         factory.createTypeWithNullability(type2, type1.isNullable()));
   }
 
+  /**
+   * Returns whether two array types are equal, ignoring nullability.
+   *
+   * <p>They need not come from the same factory.
+   *
+   * @param factory       Type factory
+   * @param type1         First type
+   * @param type2         Second type
+   * @return Whether types are equal, ignoring nullability
+   */
+  public static boolean equalAsCollectionSansNullability(
+      RelDataTypeFactory factory,
+      RelDataType type1,
+      RelDataType type2) {
+    if (type1.equals(type2)) {
+      return true;
+    }
+
+    if (isCollection(type1) && isCollection(type2)) {
+      return equalSansNullability(factory, type1.getComponentType(), 
type2.getComponentType());

Review comment:
       we should add assertion instead in the first line: `assert 
isCollection(type1) && isCollection(type2)`

##########
File path: core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
##########
@@ -1160,6 +1160,59 @@ public static boolean equalSansNullability(
         factory.createTypeWithNullability(type2, type1.isNullable()));
   }
 
+  /**
+   * Returns whether two array types are equal, ignoring nullability.
+   *
+   * <p>They need not come from the same factory.
+   *
+   * @param factory       Type factory
+   * @param type1         First type
+   * @param type2         Second type
+   * @return Whether types are equal, ignoring nullability
+   */
+  public static boolean equalAsCollectionSansNullability(
+      RelDataTypeFactory factory,
+      RelDataType type1,
+      RelDataType type2) {
+    if (type1.equals(type2)) {
+      return true;
+    }
+
+    if (isCollection(type1) && isCollection(type2)) {
+      return equalSansNullability(factory, type1.getComponentType(), 
type2.getComponentType());

Review comment:
       And should a `MULTISET` equals to `ARRAY` ? I would say no.

##########
File path: core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
##########
@@ -1160,6 +1160,59 @@ public static boolean equalSansNullability(
         factory.createTypeWithNullability(type2, type1.isNullable()));
   }
 
+  /**
+   * Returns whether two array types are equal, ignoring nullability.
+   *

Review comment:
       Fix the document.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to