github-actions[bot] commented on code in PR #66007:
URL: https://github.com/apache/doris/pull/66007#discussion_r3679293696


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSetOperation.java:
##########
@@ -311,9 +311,13 @@ private static DataType 
getAssignmentCompatibleTypeLegacy(DataType left, DataTyp
             }
             ImmutableList.Builder<StructField> commonFields = 
ImmutableList.builder();
             for (int i = 0; i < leftFields.size(); i++) {
-                boolean nullable = leftFields.get(i).isNullable() || 
rightFields.get(i).isNullable();
                 DataType commonType = getAssignmentCompatibleType(
                         leftFields.get(i).getDataType(), 
rightFields.get(i).getDataType());
+                // Legacy set operations need a nullable common child whenever 
coercing either
+                // input can itself produce NULL, even if both source fields 
are declared required.
+                boolean nullable = leftFields.get(i).isNullable() || 
rightFields.get(i).isNullable()
+                        || Cast.castNullable(false, 
leftFields.get(i).getDataType(), commonType)

Review Comment:
   [P2] Keep an unchanged datetime sibling required
   
   When the structs differ in another field, this loop also evaluates unchanged 
children. For
   example, combining
   `STRUCT<d:DATETIMEV2(3) NOT NULL,n:INT NOT NULL>` with
   `STRUCT<d:DATETIMEV2(3) NOT NULL,n:BIGINT NOT NULL>` widens only `n`, but
   `Cast.castNullable(false, d, d)` still returns true, so `d` becomes 
nullable. The BE uses an
   identity wrapper for that identical child, so it cannot introduce NULL; 
nevertheless a later
   INSERT/cast into the original required nested layout is rejected by 
`CheckCast`, and its same
   unconditional check also rejects a direct required-to-required widening of 
these structs.
   This is the inverse of the earlier thread's genuinely converted child. 
Please make exact-type
   casts preserve nullability at the shared `castNullable` boundary (or guard 
every changed
   caller, including `CheckCast` and the parallel reducers) and add two-field 
set/direct-cast
   cases.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to