liuyongvs commented on code in PR #3263:
URL: https://github.com/apache/calcite/pull/3263#discussion_r1229361974


##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeTransforms.java:
##########
@@ -111,6 +112,26 @@ public abstract class SqlTypeTransforms {
         return typeToTransform;
       };
 
+  /**
+   * Parameter type-inference transform strategy where a derived type is
+   * transformed into the same type but nullable if any of element of a calls 
operands is
+   * nullable.
+   */
+  public static final SqlTypeTransform COLLECTION_ELEMENT_TYPE_NULLABLE =
+      (opBinding, typeToTransform) -> {
+        final List<RelDataType> argComponentTypes = new ArrayList<>();
+        for (RelDataType arrayType : opBinding.collectOperandTypes()) {
+          final RelDataType componentType = 
requireNonNull(arrayType.getComponentType());
+          argComponentTypes.add(componentType);
+        }
+
+        if (argComponentTypes.stream().anyMatch(RelDataType::isNullable)) {
+          return opBinding.getTypeFactory()
+              .createTypeWithNullability(typeToTransform, true);
+        }
+        return typeToTransform;
+      };

Review Comment:
   comments:
   nullable has 4 case:
   so here does it too
   ```
   // spark
   case class ArraysOverlap(left: Expression, right: Expression)
     override def nullable: Boolean = {
       left.nullable || right.nullable || leftArrayElementNullable || 
rightArrayElementNullable
     }
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to