cloud-fan commented on code in PR #38626:
URL: https://github.com/apache/spark/pull/38626#discussion_r1021042274
##########
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.
Note that, most optimizer rules don't optimize subqueries, they need
`OptimizeSubqueries` to invoke the entire optimizer to optimize subqueries
recursively.
--
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]