rdblue commented on code in PR #9556:
URL: https://github.com/apache/iceberg/pull/9556#discussion_r1468932165
##########
spark/v3.4/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteMergeIntoTable.scala:
##########
@@ -214,6 +214,8 @@ object RewriteMergeIntoTable extends
RewriteRowLevelIcebergCommand with Predicat
val rowFromSourceAttr = resolveAttrRef(ROW_FROM_SOURCE_REF, joinPlan)
val rowFromTargetAttr = resolveAttrRef(ROW_FROM_TARGET_REF, joinPlan)
+ // The output expression should retain read attributes for correctly
determining nullability
+ val matchedOutputsWithAttrs = matchedActions.map(matchedActionOutput(_,
metadataAttrs) :+ readAttrs)
Review Comment:
Looks like the new tests pass locally with just the change to
`buildMergingOutput`.
I also think that I can explain why the nullability is incorrect. That's
because in the test case, the only expressions are constants (non-null) and
there is no explicit case that represents the existing rows.
That means there are two possible solutions. First, the one I just tested
where `buildMergingOutput` carries through the nullability of the input attrs.
Assuming that the input attrs are nullable if and only if the table fields are
nullable, that's probably the safest option. Second, the copy-on-write cases
could pass an additional seq of the input attrs to represent the unmodified
rows in the _unmatched_ set:
```scala
// line 230
output = buildMergeRowsOutput(matchedOutputs, notMatchedOutputs :+
readAttrs, readAttrs)
```
I think that I prefer the second option because the output of the
`MergeRows` node is more accurate. If an output is always present then it will
not be nullable. That's probably also safer.
I also validated that this passes tests.
--
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]