snuyanzin commented on a change in pull request #2413:
URL: https://github.com/apache/calcite/pull/2413#discussion_r631730503



##########
File path: 
core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java
##########
@@ -257,6 +260,35 @@ private RelDataType createStructType(
     return createTypeWithNullability(builder.build(), isNullable);
   }
 
+  protected @Nullable RelDataType leastRestrictiveCollectionType(
+      final List<RelDataType> types, SqlTypeName sqlTypeName) {
+    assert sqlTypeName == SqlTypeName.ARRAY
+        || sqlTypeName == SqlTypeName.MULTISET || sqlTypeName == 
SqlTypeName.MAP;
+    boolean isNullable = false;
+    for (RelDataType type : types) {
+      isNullable |= type.isNullable();
+    }
+    if (sqlTypeName == SqlTypeName.MAP) {
+      RelDataType keyType = leastRestrictive(
+          Util.transform(types, t -> Objects.requireNonNull(t.getKeyType())));

Review comment:
       > I guess with the new code, the Objects.requireNonNull in the three 
Util.transform is not necessary, since the null case has been checked (and 
early-exited) before.
   
   `Checkerframework` says that it is required for `Util.transform` to have 
`@NonNull RelDataType`, that's why it still makes sense to have 
`Objects.requireNonNull` there, otherwise `./gradlew ` with 
`Objects.requireNonNull` will fail at these lines.
   
   for others makes sense, thanks
   I updated the code
   




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