Skip to content

Commit 0fa4dbe

Browse files
gengliangwanggatorsmile
authored andcommitted
[SPARK-22141][FOLLOWUP][SQL] Add comments for the order of batches
## What changes were proposed in this pull request? Add comments for specifying the position of batch "Check Cartesian Products", as rxin suggested in apache#19362 . ## How was this patch tested? Unit test Author: Wang Gengliang <[email protected]> Closes apache#19379 from gengliangwang/SPARK-22141-followup.
1 parent 161ba7e commit 0fa4dbe

File tree

1 file changed

+4
-0
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer

1 file changed

+4
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ abstract class Optimizer(sessionCatalog: SessionCatalog)
134134
Batch("LocalRelation", fixedPoint,
135135
ConvertToLocalRelation,
136136
PropagateEmptyRelation) ::
137+
// The following batch should be executed after batch "Join Reorder" and "LocalRelation".
137138
Batch("Check Cartesian Products", Once,
138139
CheckCartesianProducts) ::
139140
Batch("OptimizeCodegen", Once,
@@ -1089,6 +1090,9 @@ object CombineLimits extends Rule[LogicalPlan] {
10891090
* SELECT * from R, S where R.r = S.s,
10901091
* the join between R and S is not a cartesian product and therefore should be allowed.
10911092
* The predicate R.r = S.s is not recognized as a join condition until the ReorderJoin rule.
1093+
*
1094+
* This rule must be run AFTER the batch "LocalRelation", since a join with empty relation should
1095+
* not be a cartesian product.
10921096
*/
10931097
object CheckCartesianProducts extends Rule[LogicalPlan] with PredicateHelper {
10941098
/**

0 commit comments

Comments
 (0)