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



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala
##########
@@ -74,12 +76,31 @@ class QueryExecution(
     sparkSession.sessionState.analyzer.executeAndCheck(logical, tracker)
   }
 
+  // SPARK-35378: Eagerly execute Command
+  // Currently, Command returns GenericInternalRow and some Exec casts the 
output
+  // of child plan to UnsafeRow. If we set Command as the child node or sub 
query,
+  // then ClassCastException occurs. Such as:
+  // java.lang.ClassCastException
+  // org.apache.spark.sql.catalyst.expressions.GenericInternalRow cannot be 
cast to
+  // org.apache.spark.sql.catalyst.expressions.UnsafeRow
+  // So eagerly executes Command and converts the output of it to UnsafeRow.
+  lazy val commandExecuted: LogicalPlan = analyzed transformDown {
+    case c: Command if isExecutingCommand == false =>

Review comment:
       I think we need code like this
   ```
   if (isExecutingCommand) {
     analyzed.mapChildren(eagerlyExecuteCommands)
   } else {
     eagerlyExecuteCommands(analyzed)
   }
   ...
   def eagerlyExecuteCommands(p: LogicalPlan) = p.transformDown {
     ...
   }
   ```




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