cloud-fan commented on a change in pull request #31968:
URL: https://github.com/apache/spark/pull/31968#discussion_r603434178



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
##########
@@ -223,11 +224,18 @@ class Dataset[T] private[sql](
   @transient private[sql] val logicalPlan: LogicalPlan = {
     // For various commands (like DDL) and queries with side effects, we force 
query execution
     // to happen right away to let these side effects take place eagerly.
+    def eagerRun(plan: LogicalPlan): LogicalPlan = {
+      val relation =
+        LocalRelation(plan.output, withAction("command", 
queryExecution)(_.executeCollect()))
+      relation.setTagValue(Dataset.DATASET_EAGER_RUN_TAG, true)
+      relation
+    }
+
     val plan = queryExecution.analyzed match {
       case c: Command =>
-        LocalRelation(c.output, withAction("command", 
queryExecution)(_.executeCollect()))

Review comment:
       It's a bit tricky to trigger a SQL execution in the middle of DataFrame 
execution. I'd prefer the other way around: we don't trigger SQL execution 
here. We follow the common code path and only trigger SQL execution at the end 
like `df.collect`.
   
   We can add some additional info to `LocalRelation`, so that its SQL UI shows 
the original command.




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to