[SPARK-41214][SQL] - SQL Metrics are missing from Spark UI when AQE for Cached DataFrame is enabled #38736
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
JIRA: https://issues.apache.org/jira/browse/SPARK-41214
spark.sql.optimizer.canChangeCachedPlanOutputPartitioningenables AQE optimizations underInMemoryRelation(IMR) nodes by creating sub-SparkPlans for AQE optimizations. However, whenspark.sql.optimizer.canChangeCachedPlanOutputPartitioning = true, Spark UI does not show correct final DAG due to lack of final sub-plans (under IMR) submissions (into UI).Why are the changes needed?
spark.sql.optimizer.canChangeCachedPlanOutputPartitioningenables AQE optimizations underInMemoryRelation(IMR) nodes. Sample query in Jira has IMR node on bothBroadcastHashJoinlegs. However,when
spark.sql.optimizer.canChangeCachedPlanOutputPartitioning = true, following datas are missed due to lack of final sub-plans (under IMR) submissions (into UI).DAG before fix:

DAG after fix:

Does this PR introduce any user-facing change?
Currently, Spark UI does not show final DAG when
spark.sql.optimizer.canChangeCachedPlanOutputPartitioning = trueso this causes some physical operators metrics as missed. This PR aims to fix this problem.How was this patch tested?
Specific UT Coverage will be added (In Progress).