@@ -27,20 +27,20 @@ import org.apache.spark.sql.catalyst.types._
27
27
import org .apache .spark .sql .columnar .{InMemoryRelation , InMemoryColumnarTableScan }
28
28
import org .apache .spark .sql .parquet ._
29
29
30
+
30
31
private [sql] abstract class SparkStrategies extends QueryPlanner [SparkPlan ] {
31
32
self : SQLContext # SparkPlanner =>
32
33
33
34
object LeftSemiJoin extends Strategy with PredicateHelper {
34
35
def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
35
36
// Find left semi joins where at least some predicates can be evaluated by matching join keys
36
37
case ExtractEquiJoinKeys (LeftSemi , leftKeys, rightKeys, condition, left, right) =>
37
- val semiJoin = execution .LeftSemiJoinHash (
38
+ val semiJoin = joins .LeftSemiJoinHash (
38
39
leftKeys, rightKeys, planLater(left), planLater(right))
39
40
condition.map(Filter (_, semiJoin)).getOrElse(semiJoin) :: Nil
40
41
// no predicate can be evaluated by matching hash keys
41
42
case logical.Join (left, right, LeftSemi , condition) =>
42
- execution.LeftSemiJoinBNL (
43
- planLater(left), planLater(right), condition) :: Nil
43
+ joins.LeftSemiJoinBNL (planLater(left), planLater(right), condition) :: Nil
44
44
case _ => Nil
45
45
}
46
46
}
@@ -50,13 +50,13 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
50
50
* evaluated by matching hash keys.
51
51
*
52
52
* This strategy applies a simple optimization based on the estimates of the physical sizes of
53
- * the two join sides. When planning a [[execution .BroadcastHashJoin ]], if one side has an
53
+ * the two join sides. When planning a [[joins .BroadcastHashJoin ]], if one side has an
54
54
* estimated physical size smaller than the user-settable threshold
55
55
* [[org.apache.spark.sql.SQLConf.AUTO_BROADCASTJOIN_THRESHOLD ]], the planner would mark it as the
56
56
* ''build'' relation and mark the other relation as the ''stream'' side. The build table will be
57
57
* ''broadcasted'' to all of the executors involved in the join, as a
58
58
* [[org.apache.spark.broadcast.Broadcast ]] object. If both estimates exceed the threshold, they
59
- * will instead be used to decide the build side in a [[execution .ShuffledHashJoin ]].
59
+ * will instead be used to decide the build side in a [[joins .ShuffledHashJoin ]].
60
60
*/
61
61
object HashJoin extends Strategy with PredicateHelper {
62
62
@@ -66,8 +66,8 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
66
66
left : LogicalPlan ,
67
67
right : LogicalPlan ,
68
68
condition : Option [Expression ],
69
- side : BuildSide ) = {
70
- val broadcastHashJoin = execution.BroadcastHashJoin (
69
+ side : joins. BuildSide ) = {
70
+ val broadcastHashJoin = execution.joins. BroadcastHashJoin (
71
71
leftKeys, rightKeys, side, planLater(left), planLater(right))
72
72
condition.map(Filter (_, broadcastHashJoin)).getOrElse(broadcastHashJoin) :: Nil
73
73
}
@@ -76,27 +76,26 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
76
76
case ExtractEquiJoinKeys (Inner , leftKeys, rightKeys, condition, left, right)
77
77
if sqlContext.autoBroadcastJoinThreshold > 0 &&
78
78
right.statistics.sizeInBytes <= sqlContext.autoBroadcastJoinThreshold =>
79
- makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, BuildRight )
79
+ makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, joins. BuildRight )
80
80
81
81
case ExtractEquiJoinKeys (Inner , leftKeys, rightKeys, condition, left, right)
82
82
if sqlContext.autoBroadcastJoinThreshold > 0 &&
83
83
left.statistics.sizeInBytes <= sqlContext.autoBroadcastJoinThreshold =>
84
- makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, BuildLeft )
84
+ makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, joins. BuildLeft )
85
85
86
86
case ExtractEquiJoinKeys (Inner , leftKeys, rightKeys, condition, left, right) =>
87
87
val buildSide =
88
88
if (right.statistics.sizeInBytes <= left.statistics.sizeInBytes) {
89
- BuildRight
89
+ joins. BuildRight
90
90
} else {
91
- BuildLeft
91
+ joins. BuildLeft
92
92
}
93
- val hashJoin =
94
- execution.ShuffledHashJoin (
95
- leftKeys, rightKeys, buildSide, planLater(left), planLater(right))
93
+ val hashJoin = joins.ShuffledHashJoin (
94
+ leftKeys, rightKeys, buildSide, planLater(left), planLater(right))
96
95
condition.map(Filter (_, hashJoin)).getOrElse(hashJoin) :: Nil
97
96
98
97
case ExtractEquiJoinKeys (joinType, leftKeys, rightKeys, condition, left, right) =>
99
- execution .HashOuterJoin (
98
+ joins .HashOuterJoin (
100
99
leftKeys, rightKeys, joinType, condition, planLater(left), planLater(right)) :: Nil
101
100
102
101
case _ => Nil
@@ -164,8 +163,12 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
164
163
def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
165
164
case logical.Join (left, right, joinType, condition) =>
166
165
val buildSide =
167
- if (right.statistics.sizeInBytes <= left.statistics.sizeInBytes) BuildRight else BuildLeft
168
- execution.BroadcastNestedLoopJoin (
166
+ if (right.statistics.sizeInBytes <= left.statistics.sizeInBytes) {
167
+ joins.BuildRight
168
+ } else {
169
+ joins.BuildLeft
170
+ }
171
+ joins.BroadcastNestedLoopJoin (
169
172
planLater(left), planLater(right), buildSide, joinType, condition) :: Nil
170
173
case _ => Nil
171
174
}
@@ -174,10 +177,10 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
174
177
object CartesianProduct extends Strategy {
175
178
def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
176
179
case logical.Join (left, right, _, None ) =>
177
- execution.CartesianProduct (planLater(left), planLater(right)) :: Nil
180
+ execution.joins. CartesianProduct (planLater(left), planLater(right)) :: Nil
178
181
case logical.Join (left, right, Inner , Some (condition)) =>
179
182
execution.Filter (condition,
180
- execution.CartesianProduct (planLater(left), planLater(right))) :: Nil
183
+ execution.joins. CartesianProduct (planLater(left), planLater(right))) :: Nil
181
184
case _ => Nil
182
185
}
183
186
}
0 commit comments