uros-b commented on code in PR #56705:
URL: https://github.com/apache/spark/pull/56705#discussion_r3466673151


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala:
##########
@@ -1166,6 +1170,44 @@ case class MergeIntoTable(
   }
 }
 
+/**
+ * The logical plan of the `INSERT INTO t REPLACE USING (cols) <query>` 
command, resolved from
+ * [[InsertIntoStatement]] when its replace criteria is an 
[[InsertReplaceUsing]].
+ *
+ * Scoped replace deletes every target row whose scope-column tuple appears in 
the source and
+ * appends all source rows, including duplicates that share the same scope 
tuple. The command uses
+ * [[RowLevelOperation.Command.REPLACE]] so connectors can distinguish this 
scope-level replacement
+ * from per-row MERGE semantics.
+ *
+ * @param targetTable the target relation to replace rows in
+ * @param scopeColumns unqualified target column names whose values define a 
replace scope tuple
+ * @param query        the source query, already aligned to the target table 
output
+ */
+case class ReplaceUsingTable(
+    targetTable: LogicalPlan,
+    scopeColumns: Seq[String],
+    query: LogicalPlan)
+    extends BinaryCommand with SupportsSubquery with TransactionalWrite {
+
+  override def table: LogicalPlan = EliminateSubqueryAliases(targetTable)
+
+  lazy val rewritable: Boolean = {

Review Comment:
   Please confirm - ReplaceUsingTable.rewritable lazy val might be dead code. 
Unlike MergeIntoTable / UpdateTable, which use rewritable as a case-guard, 
RewriteReplaceUsing never references r.rewritable. Either wire it into the rule 
guard for consistency or remove it.
   



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