tokoko commented on code in PR #52185:
URL: https://github.com/apache/spark/pull/52185#discussion_r4476944411
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteMergeIntoTable.scala:
##########
@@ -174,16 +174,29 @@ object RewriteMergeIntoTable extends
RewriteRowLevelCommand with PredicateHelper
readRelation, joinPlan, matchedActions, notMatchedActions,
notMatchedBySourceActions, metadataAttrs, checkCardinality)
- // predicates of the ON condition can be used to filter the target table
(planning & runtime)
+ // predicates that can be used to filter the target table (planning):
+ // - without NOT MATCHED BY SOURCE clauses, target rows that don't satisfy
the ON condition
+ // match no action and are simply carried over, so the ON condition can
filter the target
+ // - if every NOT MATCHED BY SOURCE clause is conditional, a target row
can be skipped only
+ // if it satisfies neither the ON condition nor any of those conditions,
so the filter is
+ // their disjunction; only the target-only part of the ON condition can
take part, as a
+ // disjunction that references the source is not a valid filter for the
target table
+ // - an unconditional NOT MATCHED BY SOURCE clause matches any target row
and disables this
+ val pushableCond = if (notMatchedBySourceActions.isEmpty) {
+ cond
+ } else if (notMatchedBySourceActions.exists(_.condition.isEmpty)) {
+ TrueLiteral
+ } else {
+ val (targetCond, _) = splitTargetPredicates(readRelation, cond)
+ (targetCond +: notMatchedBySourceActions.flatMap(_.condition)).reduce(Or)
Review Comment:
Confirmed with a new failing test. Fixed with the CHAR guard, which is
described as a stopgap until ApplyCharTypePadding is fixed separately.
--
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]