aokolnychyi commented on code in PR #55612:
URL: https://github.com/apache/spark/pull/55612#discussion_r3164829112


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteRowLevelCommand.scala:
##########
@@ -47,6 +47,21 @@ trait RewriteRowLevelCommand extends Rule[LogicalPlan] {
 
   protected def groupFilterEnabled: Boolean = 
conf.runtimeRowLevelOperationGroupFilterEnabled
 
+  // converts a MERGE condition into an EXISTS subquery for runtime filtering
+  protected def toMergeGroupFilterCondition(

Review Comment:
   Oops, forgot to revert. Fixed.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala:
##########
@@ -484,3 +484,56 @@ object GroupBasedRowLevelOperation {
     }
   }
 }
+
+/**
+ * An extractor for row-level commands such as DELETE, UPDATE, MERGE that were 
rewritten using plans
+ * that operate on individual rows (row deltas).
+ *
+ * This class extracts the following entities:
+ *  - the delta-based rewrite plan;
+ *  - the condition that defines matching rows;
+ *  - the group filter condition;
+ *  - the read relation that can be either [[DataSourceV2Relation]] or 
[[DataSourceV2ScanRelation]]
+ *  depending on whether the planning has already happened;
+ */
+object DeltaBasedRowLevelOperation {
+  type ReturnType = (WriteDelta, Expression, Option[Expression], LogicalPlan)
+
+  def unapply(plan: LogicalPlan): Option[ReturnType] = plan match {
+    case wd @ WriteDelta(ExtractV2Table(table), cond, query, _, _, 
groupFilterCond, _) =>
+      val readRelation = findReadRelation(table, query)
+      readRelation.map((wd, cond, groupFilterCond, _))
+
+    case _ =>
+      None
+  }
+
+  private def findReadRelation(

Review Comment:
   Refactored.



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

Reply via email to