You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/02/01 04:46:43 UTC

[GitHub] [iceberg] aokolnychyi commented on a change in pull request #2189: Spark: Optimize insert only case in MERGE

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



##########
File path: spark3-extensions/src/main/scala/org/apache/spark/sql/catalyst/optimizer/RewriteMergeInto.scala
##########
@@ -158,6 +144,43 @@ case class RewriteMergeInto(spark: SparkSession) extends Rule[LogicalPlan] with
     }
   }
 
+  // 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.
+  private def buildInsertOnlyMergePlan(
+      targetTableScan: LogicalPlan,
+      targetTableOutput: Seq[AttributeReference],
+      source: LogicalPlan,
+      cond: Expression,
+      notMatchedActions: Seq[MergeAction]): LogicalPlan = {
+
+    notMatchedActions match {
+      case Seq(insertAction: InsertAction) =>
+        val filteredSource = insertAction.condition match {

Review comment:
       In case of a filter in `NOT MATCHED` clause, we can execute it before the join.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org