rdblue commented on a change in pull request #2189:
URL: https://github.com/apache/iceberg/pull/2189#discussion_r568172673



##########
File path: 
spark3-extensions/src/main/scala/org/apache/spark/sql/catalyst/optimizer/RewriteMergeInto.scala
##########
@@ -72,23 +74,7 @@ case class RewriteMergeInto(spark: SparkSession) extends 
Rule[LogicalPlan] with
           if matchedActions.isEmpty && isIcebergRelation(target) =>
 
         val targetTableScan = buildSimpleScanPlan(target, cond)
-
-        // when there are no matched actions, use a left anti join to remove 
any matching rows and rewrite to use
-        // append instead of replace. only unmatched source rows are passed to 
the merge and actions are all inserts.
-        val joinPlan = Join(source, targetTableScan, LeftAnti, Some(cond), 
JoinHint.NONE)
-
-        val mergeParams = MergeIntoParams(
-          isSourceRowNotPresent = FALSE_LITERAL,
-          isTargetRowNotPresent = TRUE_LITERAL,
-          matchedConditions = Nil,
-          matchedOutputs = Nil,
-          notMatchedConditions = notMatchedActions.map(getClauseCondition),
-          notMatchedOutputs = notMatchedActions.map(actionOutput),
-          targetOutput = Nil,
-          joinedAttributes = joinPlan.output
-        )
-
-        val mergePlan = MergeInto(mergeParams, target.output, joinPlan)
+        val mergePlan = buildInsertOnlyMergePlan(targetTableScan, 
target.output, source, cond, notMatchedActions)

Review comment:
       Why create a new method rather than adding another case to this match?
   
   ```scala
       case MergeIntoTable(target: DataSourceV2Relation, source, cond, 
matchedActions, notMatchedActions)
           if matchedActions.isEmpty && notMatchedActions.size == 1 && 
isIcebergRelation(target) =>
   ```




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

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