You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "cloud-fan (via GitHub)" <gi...@apache.org> on 2025/08/01 11:56:59 UTC

Re: [PR] [SPARK-52451][CONNECT][SQL] Make WriteOperation in SparkConnectPlanner side effect free [spark]

cloud-fan commented on code in PR #51727:
URL: https://github.com/apache/spark/pull/51727#discussion_r2247794830


##########
sql/core/src/main/scala/org/apache/spark/sql/classic/DataFrameWriter.scala:
##########
@@ -551,17 +551,31 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) extends sql.DataFram
           case _ => // OK
         }
 
-        // Drop the existing table
-        catalog.dropTable(qualifiedIdent, ignoreIfNotExists = true, purge = false)
-        createTable(qualifiedIdent)
-        // Refresh the cache of the table in the catalog.
-        catalog.refreshTable(qualifiedIdent)
+        val dropTablePlan = DropTableCommand(
+          qualifiedIdent,
+          ifExists = true,
+          isView = tableRelation.isInstanceOf[org.apache.spark.sql.catalyst.plans.logical.View],
+          purge = false)
+
+        val createTablePlan = createTableLogicalPlan(qualifiedIdent)
+
+        val refreshTablePlan = RefreshTableCommand(qualifiedIdent)
+
+        CompoundBody(

Review Comment:
   I'm a bit worried about using `CompoundBody` outside of SQL script execution, and the fix in https://github.com/apache/spark/pull/51727/files#diff-a3fb0a56a7d2d08dc87434eff5b43aba0b006b59ed2f25e29bfb6fb4f81ec0c4R164 is a bit suspicious.
   
   Can we create a new command `SaveAsTableCommand` to do these operations? 



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