cloud-fan commented on a change in pull request #32513:
URL: https://github.com/apache/spark/pull/32513#discussion_r646323000
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala
##########
@@ -73,23 +75,55 @@ class QueryExecution(
sparkSession.sessionState.analyzer.executeAndCheck(logical, tracker)
}
+ // SPARK-35378: Commands should be executed eagerly so that `sql("INSERT
...")` can trigger the
+ // table insertion immediately without a `.collect()`. We also need to
eagerly execute non-root
+ // commands, because many commands return `GenericInternalRow` and can't be
put in a query plan
+ // directly, otherwise the query engine may cast `GenericInternalRow` to
`UnsafeRow` and fail.
Review comment:
now it seems better to put the doc in `CommandExecutionMode`
```
// SPARK-35378: Commands should be executed eagerly so that something like
`sql("INSERT ...")`
// can trigger the table insertion immediately without a `.collect()`. To
avoid end-less recursion we
// should use `NON_ROOT` when recursively executing commands. Note that we
can't execute
// a query plan with leaf command nodes, because many commands return
`GenericInternalRow`
// and can't be put in a query plan directly, otherwise the query engine may
cast `GenericInternalRow`
// to `UnsafeRow` and fail. When running EXPLAIN, we should use `SKIP` to
not trigger any execution.
object CommandExecutionMode extends Enumeration {
val SKIP, NON_ROOT, ALL = Value
}
```
--
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]