You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/06/20 19:29:12 UTC

[GitHub] [iceberg] rdblue commented on a diff in pull request #5083: support update/delete/merge into on hadoopTables using Spark

rdblue commented on code in PR #5083:
URL: https://github.com/apache/iceberg/pull/5083#discussion_r901955352


##########
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 relations = v.children.collect { case r: DataSourceV2Relation if r.table.isInstanceOf[SparkTable] =>

Review Comment:
   I think the logic here needs to be much more strict. I think this should validate that `v.child` is the `DataSourceV2Relation`. Almost any other nodes in the logical plan would make this invalid. For example, if you had registered `table.select(...)` instead of just `table`, then it is unclear what deleting from that view should do. We only want to support this if the plan is only a relation.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org