yuexing commented on code in PR #51013:
URL: https://github.com/apache/spark/pull/51013#discussion_r2111481718


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala:
##########
@@ -215,6 +216,14 @@ class QueryExecution(
   }
 
   def optimizedPlan: LogicalPlan = lazyOptimizedPlan.get
+  // Eliminate SubqueryAliases from the optimized plan to help correct the 
explain result.
+  def optimizedPlanWithoutSubqueries: LogicalPlan = {
+    optimizedPlan match {
+      case s: CreateDataSourceTableAsSelectCommand =>
+        s.copy(query = EliminateSubqueryAliases(s.query))

Review Comment:
   because EliminateSubqueryAliases doesn't handle Command. That's why we have 
this unexpected explain result.
   - CreateDataSourceTableAsSelectCommand as logic plan, 
EliminateSubqueryAliases doesn't handle command.query
   -  ExecutedCommandExec(cmd=CreateDataSourceTableAsSelectCommand)  as 
physical plan, upon run will create a new QueryExecution with command.query. 
This is the time execution gets EliminateSubqueryAliases (as well as other 
optimization)
   
   @LuciferYang 



-- 
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-unsubscr...@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to