rdblue commented on a change in pull request #23606: [SPARK-26666][SQL] Support
DSv2 overwrite and dynamic partition overwrite.
URL: https://github.com/apache/spark/pull/23606#discussion_r255747563
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
##########
@@ -386,16 +387,66 @@ case class AppendData(
}
}
+/**
+ * Append data to an existing table.
+ */
+case class AppendData(
+ table: NamedRelation,
+ query: LogicalPlan,
+ isByName: Boolean) extends V2WriteCommand
+
object AppendData {
def byName(table: NamedRelation, df: LogicalPlan): AppendData = {
- new AppendData(table, df, true)
+ new AppendData(table, df, isByName = true)
}
def byPosition(table: NamedRelation, query: LogicalPlan): AppendData = {
- new AppendData(table, query, false)
+ new AppendData(table, query, isByName = false)
}
}
+/**
+ * Overwrite data matching a filter in an existing table.
+ */
+case class OverwriteByExpression(
+ table: NamedRelation,
+ deleteExpr: Expression,
+ query: LogicalPlan,
+ isByName: Boolean) extends V2WriteCommand {
+ override lazy val resolved: Boolean = writeResolved && deleteExpr.resolved
+}
+
+object OverwriteByExpression {
+ def byName(
+ table: NamedRelation, df: LogicalPlan, deleteExpr: Expression):
OverwriteByExpression = {
+ OverwriteByExpression(table, deleteExpr, df, isByName = true)
+ }
+
+ def byPosition(
+ table: NamedRelation, query: LogicalPlan, deleteExpr: Expression):
OverwriteByExpression = {
+ OverwriteByExpression(table, deleteExpr, query, isByName = false)
+ }
+}
+
+/**
+ * Dynamically overwrite partitions in an existing table.
+ */
+case class OverwritePartitionsDynamic(
Review comment:
Yes, remember that the DataFrameWriter API is ambiguous, partly because it
uses SaveMode and partly because it isn't clear what "save" or "saveAsTable"
mean. A better plan is to introduce an API that has obvious behavior, like the
one proposed in the logical plans SPIP.
In the short term, this plan will be available from SQL because it
implements one of the modes for `INSERT OVERWRITE`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]