You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/06/16 03:45:17 UTC

[GitHub] [calcite] Aaaaaaron commented on a change in pull request #2019: [CALCITE-4059] SqlTypeUtil#equalSansNullability consider Array/Map type.

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



##########
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:
       > I would suggest to add two new methods `equalAsArraySansNullability` and `equalsAsMapSansNullability`, because for most of the cases when we invoke these methods, we already know if the type to compare is a map/array/struct, add new methods simplify the original impl(which is the most common case).
   
   Thanks for your advice, I'll change this latter.




----------------------------------------------------------------
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:
users@infra.apache.org