viirya commented on code in PR #38626:
URL: https://github.com/apache/spark/pull/38626#discussion_r1021159125


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkOptimizer.scala:
##########
@@ -51,8 +51,10 @@ class SparkOptimizer(
     Batch("Optimize Metadata Only Query", Once, 
OptimizeMetadataOnlyQuery(catalog)) :+
     Batch("PartitionPruning", Once,
       PartitionPruning,
-      RowLevelOperationRuntimeGroupFiltering,
-      OptimizeSubqueries) :+
+      // We can't run `OptimizeSubqueries` in this batch, as it will optimize 
the subqueries
+      // twice which may break some optimizer rules that can only be applied 
once. The rule below
+      // only invokes `OptimizeSubqueries` to optimize newly added subqueries.

Review Comment:
   > All the optimizer batches are optimizing the same query plan. If 
`OptimizeSubqueries` appears twice, it means the subqueries are optimized twice.
   
   Oh, got it, you actually mean `OptimizeSubqueries` is applied twice (here 
and `Optimizer`). I thought that by running `OptimizeSubqueries` itself here 
breaks some rules which cannot run twice.



-- 
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: [email protected]

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