WeichenXu123 opened a new pull request #25359: [SPARK-28621][SQL] Fix CheckCartesianProducts.isCartesianProduct URL: https://github.com/apache/spark/pull/25359 ## What changes were proposed in this pull request? Fix `CheckCartesianProducts.isCartesianProduct` so that 1) when left or right side table can broadcast, then do not raise `Detected implicit cartesian product...` exception. 2) when left or right side table both cannot broadcast and join conditions do not include equi-condition, then raise `Detected implicit cartesian product...` exception. ## How was this patch tested? Manual. Providing ``` spark.range(2).createOrReplaceTempView("sm1") // can be broadcast spark.range(50000000).createOrReplaceTempView("bg1") // cannot be broadcast spark.range(60000000).createOrReplaceTempView("bg2") // cannot be broadcast ``` and suppose `spark.sql.crossJoin.enabled=false` ### Test1 Run ``` spark.sql("select sm1.id, bg1.id from bg1 join sm1 where sm1.id < bg1.id").explain ``` **Before**: `Detected implicit cartesian product...` exception raised. **After**: Print correct sql plan like: ``` == Physical Plan == *(3) Project [id#10L, id#0L] +- BroadcastNestedLoopJoin BuildRight, Inner, (id#10L < id#0L) :- *(1) Range (0, 50000000, step=1, splits=1) +- BroadcastExchange IdentityBroadcastMode +- *(2) Range (0, 2, step=1, splits=1) ``` ### Test2 Run ``` spark.sql("select bg2.id, bg1.id from bg1 join bg2 where bg2.id < bg1.id").explain ``` **Before** Print planner include Cartesian join (BUT we expect a `Detected implicit cartesian product...` exception raised): ``` == Physical Plan == *(3) Project [id#0L, id#2L] +- CartesianProduct (id#0L < id#2L) :- *(1) Range (0, 50000000, step=1, splits=1) +- *(2) Range (0, 60000000, step=1, splits=1) ``` **After**: `Detected implicit cartesian product...` exception raised. Please review https://spark.apache.org/contributing.html before opening a pull request.
---------------------------------------------------------------- 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]
