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 2021/05/12 10:48:27 UTC

[GitHub] [calcite] snuyanzin commented on a change in pull request #2413: [CALCITE-4603] Least restrictive for collections of collections

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



##########
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:
       thanks for highlighting this. 
   Yes it definitely makes sense. The  only thing is that it seems that casting from `MULTISET` to `ARRAY` and vice versa is allowed and even used in `JdbcTest`. So I would go with check that either all the types have non null component info or all the types have keytype and valuetype




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