zhuxiangyi commented on code in PR #8334:
URL: https://github.com/apache/paimon/pull/8334#discussion_r3795049301


##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/DataEvolutionMergeIntoAction.java:
##########
@@ -527,7 +681,23 @@ private void checkSchema(Table source) {
                                         .getTypeRoot()
                                         .getFamilies()
                                         
.contains(DataTypeFamily.BINARY_STRING);
+                // Struct columns need a structural compatibility check: 
DataTypeCasts does not
+                // support ROW-to-ROW casts. For a sub-field write (dotted 
paths like nest.a) the
+                // source is a partial (subset) struct carrying only the 
updated sub-fields, so a
+                // subset check is correct. For a whole-column assignment 
(e.g. T.nest=S.nest) the
+                // source must fully cover the target struct, so a narrower 
source is rejected
+                // instead of being written as an incomplete whole-struct file.
+                boolean structCompatible = false;
+                if (paimonType instanceof RowType && targetField.type() 
instanceof RowType) {
+                    RowType sourceStruct = (RowType) paimonType;
+                    RowType targetStruct = (RowType) targetField.type();
+                    structCompatible =
+                            isSubFieldWrite(flinkColumn.getName())
+                                    ? isCompatiblePartialStruct(sourceStruct, 
targetStruct)
+                                    : isFullyCompatibleStruct(sourceStruct, 
targetStruct);

Review Comment:
   Fixed with the second option you offered — reject rather than rebuild. 
isFullyCompatibleSt arity and the same field name at each position, recursing 
into nested rows, so a reordered or wider source is refused instead of being 
written under the wrong names.



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