You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/03/25 03:09:30 UTC
[GitHub] [spark] jackylee-ch commented on a change in pull request #35395: [SPARK-38085][SQL] DataSource V2: Handle DELETE commands for group-based sources
jackylee-ch commented on a change in pull request #35395:
URL: https://github.com/apache/spark/pull/35395#discussion_r834919726
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
##########
@@ -446,17 +501,52 @@ object DescribeColumn {
def getOutputAttrs: Seq[Attribute] = DescribeCommandSchema.describeColumnAttributes()
}
+trait RowLevelCommand extends Command with SupportsSubquery {
+ def condition: Expression
+ def rewritePlan: Option[LogicalPlan]
+ def withNewRewritePlan(newRewritePlan: LogicalPlan): RowLevelCommand
+}
+
/**
* The logical plan of the DELETE FROM command.
*/
case class DeleteFromTable(
table: LogicalPlan,
- condition: Expression) extends UnaryCommand with SupportsSubquery {
- override def child: LogicalPlan = table
- override protected def withNewChildInternal(newChild: LogicalPlan): DeleteFromTable =
- copy(table = newChild)
+ condition: Expression,
+ rewritePlan: Option[LogicalPlan] = None) extends RowLevelCommand {
+
+ override def children: Seq[LogicalPlan] = if (rewritePlan.isDefined) {
+ table :: rewritePlan.get :: Nil
+ } else {
+ table :: Nil
+ }
+
+ override def withNewRewritePlan(newRewritePlan: LogicalPlan): RowLevelCommand = {
+ copy(rewritePlan = Some(newRewritePlan))
+ }
+
+ override protected def withNewChildrenInternal(
+ newChildren: IndexedSeq[LogicalPlan]): DeleteFromTable = {
+ if (newChildren.size == 1) {
+ copy(table = newChildren.head, rewritePlan = None)
+ } else {
+ require(newChildren.size == 2, "DeleteFromTable expects either one or two children")
+ val Seq(newTable, newRewritePlan) = newChildren.take(2)
+ copy(table = newTable, rewritePlan = Some(newRewritePlan))
Review comment:
nit:
```
newChildren match {
case Seq(newChild) =>
xxx
case Seq(_, newChild) =>
xxx
case _ =>
throw exception/error
}
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org