CodingCat commented on code in PR #5083:
URL: https://github.com/apache/iceberg/pull/5083#discussion_r910612095
##########
spark/v3.2/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteDeleteFromTable.scala:
##########
@@ -49,25 +51,42 @@ import
org.apache.spark.sql.execution.datasources.v2.DataSourceV2Relation
object RewriteDeleteFromTable extends RewriteRowLevelCommand {
override def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
- case d @ DeleteFromIcebergTable(aliasedTable, Some(cond), None) if
d.resolved =>
+ case d @ DeleteFromIcebergTable(aliasedTable, Some(_), None) if d.resolved
=>
EliminateSubqueryAliases(aliasedTable) match {
case r @ DataSourceV2Relation(tbl: SupportsRowLevelOperations, _, _,
_, _) =>
- val operation = buildRowLevelOperation(tbl, DELETE)
- val table = RowLevelOperationTable(tbl, operation)
- val rewritePlan = operation match {
- case _: SupportsDelta =>
- buildWriteDeltaPlan(r, table, cond)
- case _ =>
- buildReplaceDataPlan(r, table, cond)
+ rewriteDeleteFromTable(d, r, tbl)
+ case v: View =>
+ val viewChild = v.child
+ val icebergTableView = v.children.size == 1 &&
viewChild.isInstanceOf[DataSourceV2Relation] &&
+
viewChild.asInstanceOf[DataSourceV2Relation].table.isInstanceOf[SparkTable]
+ if (icebergTableView) {
+ val dataSourceV2Relation =
viewChild.asInstanceOf[DataSourceV2Relation]
+ rewriteDeleteFromTable(d, dataSourceV2Relation,
+
dataSourceV2Relation.table.asInstanceOf[SupportsRowLevelOperations])
+ } else {
+ throw new AnalysisException(s"$v is not an Iceberg table")
Review Comment:
sure, updated
##########
spark/v3.2/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteDeleteFromTable.scala:
##########
@@ -49,25 +51,42 @@ import
org.apache.spark.sql.execution.datasources.v2.DataSourceV2Relation
object RewriteDeleteFromTable extends RewriteRowLevelCommand {
override def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
- case d @ DeleteFromIcebergTable(aliasedTable, Some(cond), None) if
d.resolved =>
+ case d @ DeleteFromIcebergTable(aliasedTable, Some(_), None) if d.resolved
=>
EliminateSubqueryAliases(aliasedTable) match {
case r @ DataSourceV2Relation(tbl: SupportsRowLevelOperations, _, _,
_, _) =>
- val operation = buildRowLevelOperation(tbl, DELETE)
- val table = RowLevelOperationTable(tbl, operation)
- val rewritePlan = operation match {
- case _: SupportsDelta =>
- buildWriteDeltaPlan(r, table, cond)
- case _ =>
- buildReplaceDataPlan(r, table, cond)
+ rewriteDeleteFromTable(d, r, tbl)
+ case v: View =>
+ val viewChild = v.child
+ val icebergTableView = v.children.size == 1 &&
viewChild.isInstanceOf[DataSourceV2Relation] &&
+
viewChild.asInstanceOf[DataSourceV2Relation].table.isInstanceOf[SparkTable]
Review Comment:
updated
--
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]