NobiGo commented on code in PR #4458:
URL: https://github.com/apache/calcite/pull/4458#discussion_r2188783114


##########
core/src/test/resources/sql/cast.iq:
##########
@@ -1918,4 +1918,43 @@ EnumerableCalc(expr#0=[{inputs}], 
expr#1=[1.11:DECIMAL(3, 2)], expr#2=[2.22:DECI
   EnumerableValues(tuples=[[{ 0 }]])
 !plan
 
+# [CALCITE-7062]
+# Common type for nullable date and not nullable timestamp
+SELECT CAST(NULL AS DATE) UNION ALL SELECT TIMESTAMP '2025-07-04 10:00:00';
++---------------------+
+| EXPR$0              |
++---------------------+
+|                     |
+| 2025-07-04 10:00:00 |
++---------------------+
+(2 rows)
+
+!ok
+
+# [CALCITE-7062]
+# Common type for null and not nullable array;
+SELECT ARRAY[1, 2, 3] UNION ALL SELECT NULL;

Review Comment:
   We need to add additional test cases such as:
   ```
   SELECT ARRAY[cast(null as integer), cast(null as integer), cast(null as 
integer)] UNION ALL SELECT NULL;
   ```
   Or:
   ```
   SELECT ARRAY[cast(null as integer), cast(null as integer), cast(null as 
integer)] UNION ALL SELECT ARRAY[1, 2, 3];
   ```



##########
core/src/test/resources/sql/cast.iq:
##########
@@ -1918,4 +1918,43 @@ EnumerableCalc(expr#0=[{inputs}], 
expr#1=[1.11:DECIMAL(3, 2)], expr#2=[2.22:DECI
   EnumerableValues(tuples=[[{ 0 }]])
 !plan
 
+# [CALCITE-7062]

Review Comment:
   Please reformat [CALCITE-7062] xxxxxxxxx like others.



##########
core/src/main/java/org/apache/calcite/sql/SqlCollectionTypeNameSpec.java:
##########
@@ -58,32 +58,51 @@
  */
 public class SqlCollectionTypeNameSpec extends SqlTypeNameSpec {
   private final SqlTypeNameSpec elementTypeName;
+  private final boolean elementTypeNullable;
   private final SqlTypeName collectionTypeName;
 
   /**
    * Creates a {@code SqlCollectionTypeNameSpec}.
    *
    * @param elementTypeName    Type of the collection element
+   * @param elementTypeNullable Type of the collection element is nullable
    * @param collectionTypeName Collection type name
    * @param pos                Parser position, must not be null
    */
   public SqlCollectionTypeNameSpec(SqlTypeNameSpec elementTypeName,
+      boolean elementTypeNullable,
       SqlTypeName collectionTypeName,
       SqlParserPos pos) {
     super(new SqlIdentifier(collectionTypeName.name(), pos), pos);
     this.elementTypeName = requireNonNull(elementTypeName, "elementTypeName");
+    this.elementTypeNullable = elementTypeNullable;
     this.collectionTypeName =
         requireNonNull(collectionTypeName, "collectionTypeName");
   }
 
+  /**
+   * Creates a {@code SqlCollectionTypeNameSpec}.
+   *
+   * @param elementTypeName    Type of the collection element
+   * @param collectionTypeName Collection type name
+   * @param pos                Parser position, must not be null
+   */
+  public SqlCollectionTypeNameSpec(SqlTypeNameSpec elementTypeName,
+      SqlTypeName collectionTypeName,
+      SqlParserPos pos) {
+    this(elementTypeName, true, collectionTypeName, pos);
+  }
+
   public SqlTypeNameSpec getElementTypeName() {
     return elementTypeName;
   }
 
   @Override public RelDataType deriveType(SqlValidator validator) {
     RelDataType type = elementTypeName.deriveType(validator);
     // We have to assume that elements may be nullable

Review Comment:
   The code comments need to be updated.



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