WangGuangxin opened a new pull request #26726: [SPARK-30088][SQL]Adaptive 
execution should convert SortMergeJoin to BroadcastJoin when plan generates 
empty result
URL: https://github.com/apache/spark/pull/26726
 
 
   ### What changes were proposed in this pull request?
   Adaptive execution should convert `SortMergeJoin` to `BroadcastJoin` if the 
subquery generates empty result. 
   
   ### Why are the changes needed?
   Adaptive execution try to  convert `SortMergeJoin` to `BroadcastJoin` by 
checking the `dataSize` metrics of spark plan. However, if the spark plan 
generates empty result, the `dataSize` metrics is empty due to 
`org.apache.spark.sql.execution.metric.SQLMetrics`'s initial value is -1, which 
could lead to the following check return `false`
   
   ```
   private def canBroadcast(plan: LogicalPlan): Boolean = {
     plan.stats.sizeInBytes >= 0 && plan.stats.sizeInBytes <= 
conf.autoBroadcastJoinThreshold
   }
   ```
   
   ### Does this PR introduce any user-facing change?
   No
   
   ### How was this patch tested?
   Adding a test case in `AdaptiveQueryExecSuite`
   

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to