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



##########
File path: core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
##########
@@ -1151,13 +1151,22 @@ public static boolean equalSansNullability(
       return true;
     }
 
-    if (type1.isNullable() == type2.isNullable()) {
+    if (isAtomic(type1) && isAtomic(type2) && (type1.isNullable() == 
type2.isNullable())) {
       // If types have the same nullability and they weren't equal above,
       // they must be different.
       return false;
     }
-    return type1.equals(
-        factory.createTypeWithNullability(type2, type1.isNullable()));
+    if (isArray(type1) && isArray(type2)) {
+      return equalSansNullability(factory, type1.getComponentType(), 
type2.getComponentType());
+    } else if (isMap(type1) && isMap(type2)) {
+      MapSqlType mType1 = (MapSqlType) type1;

Review comment:
       > BTW, can you share why you need to compare map and array types ? Seems 
the case is rare from my side.
   
   A case like this: array(12L) will be recognized as "INTEGER ARRAY, NOT 
NULL", but the col i_ids is "BIGINT ARRAY NULLABLE", so calcite will add a 
cast. But the source/targe nullability is still different, and we don't want to 
consider nullability.
   
   ```
   INSERT TABLE new_t
   SELECT id,
          array(12) AS i_ids,
   FROM t
   ```
   




----------------------------------------------------------------
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:
[email protected]


Reply via email to