@@ -27,20 +27,19 @@ import org.apache.spark.sql.catalyst.types._
2727import org .apache .spark .sql .columnar .{InMemoryRelation , InMemoryColumnarTableScan }
2828import org .apache .spark .sql .parquet ._
2929
30+
3031private [sql] abstract class SparkStrategies extends QueryPlanner [SparkPlan ] {
3132 self : SQLContext # SparkPlanner =>
3233
3334 object LeftSemiJoin extends Strategy with PredicateHelper {
3435 def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
3536 // Find left semi joins where at least some predicates can be evaluated by matching join keys
3637 case ExtractEquiJoinKeys (LeftSemi , leftKeys, rightKeys, condition, left, right) =>
37- val semiJoin = execution.LeftSemiJoinHash (
38- leftKeys, rightKeys, planLater(left), planLater(right))
38+ val semiJoin = join.LeftSemiJoinHash (leftKeys, rightKeys, planLater(left), planLater(right))
3939 condition.map(Filter (_, semiJoin)).getOrElse(semiJoin) :: Nil
4040 // no predicate can be evaluated by matching hash keys
4141 case logical.Join (left, right, LeftSemi , condition) =>
42- execution.LeftSemiJoinBNL (
43- planLater(left), planLater(right), condition) :: Nil
42+ join.LeftSemiJoinBNL (planLater(left), planLater(right), condition) :: Nil
4443 case _ => Nil
4544 }
4645 }
@@ -50,13 +49,13 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
5049 * evaluated by matching hash keys.
5150 *
5251 * 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
52+ * the two join sides. When planning a [[join .BroadcastHashJoin ]], if one side has an
5453 * estimated physical size smaller than the user-settable threshold
5554 * [[org.apache.spark.sql.SQLConf.AUTO_BROADCASTJOIN_THRESHOLD ]], the planner would mark it as the
5655 * ''build'' relation and mark the other relation as the ''stream'' side. The build table will be
5756 * ''broadcasted'' to all of the executors involved in the join, as a
5857 * [[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 ]].
58+ * will instead be used to decide the build side in a [[join .ShuffledHashJoin ]].
6059 */
6160 object HashJoin extends Strategy with PredicateHelper {
6261
@@ -66,8 +65,8 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
6665 left : LogicalPlan ,
6766 right : LogicalPlan ,
6867 condition : Option [Expression ],
69- side : BuildSide ) = {
70- val broadcastHashJoin = execution.BroadcastHashJoin (
68+ side : join. BuildSide ) = {
69+ val broadcastHashJoin = execution.join. BroadcastHashJoin (
7170 leftKeys, rightKeys, side, planLater(left), planLater(right))
7271 condition.map(Filter (_, broadcastHashJoin)).getOrElse(broadcastHashJoin) :: Nil
7372 }
@@ -76,27 +75,26 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
7675 case ExtractEquiJoinKeys (Inner , leftKeys, rightKeys, condition, left, right)
7776 if sqlContext.autoBroadcastJoinThreshold > 0 &&
7877 right.statistics.sizeInBytes <= sqlContext.autoBroadcastJoinThreshold =>
79- makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, BuildRight )
78+ makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, join. BuildRight )
8079
8180 case ExtractEquiJoinKeys (Inner , leftKeys, rightKeys, condition, left, right)
8281 if sqlContext.autoBroadcastJoinThreshold > 0 &&
8382 left.statistics.sizeInBytes <= sqlContext.autoBroadcastJoinThreshold =>
84- makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, BuildLeft )
83+ makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, join. BuildLeft )
8584
8685 case ExtractEquiJoinKeys (Inner , leftKeys, rightKeys, condition, left, right) =>
8786 val buildSide =
8887 if (right.statistics.sizeInBytes <= left.statistics.sizeInBytes) {
89- BuildRight
88+ join. BuildRight
9089 } else {
91- BuildLeft
90+ join. BuildLeft
9291 }
93- val hashJoin =
94- execution.ShuffledHashJoin (
95- leftKeys, rightKeys, buildSide, planLater(left), planLater(right))
92+ val hashJoin = join.ShuffledHashJoin (
93+ leftKeys, rightKeys, buildSide, planLater(left), planLater(right))
9694 condition.map(Filter (_, hashJoin)).getOrElse(hashJoin) :: Nil
9795
9896 case ExtractEquiJoinKeys (joinType, leftKeys, rightKeys, condition, left, right) =>
99- execution .HashOuterJoin (
97+ join .HashOuterJoin (
10098 leftKeys, rightKeys, joinType, condition, planLater(left), planLater(right)) :: Nil
10199
102100 case _ => Nil
@@ -164,8 +162,12 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
164162 def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
165163 case logical.Join (left, right, joinType, condition) =>
166164 val buildSide =
167- if (right.statistics.sizeInBytes <= left.statistics.sizeInBytes) BuildRight else BuildLeft
168- execution.BroadcastNestedLoopJoin (
165+ if (right.statistics.sizeInBytes <= left.statistics.sizeInBytes) {
166+ join.BuildRight
167+ } else {
168+ join.BuildLeft
169+ }
170+ join.BroadcastNestedLoopJoin (
169171 planLater(left), planLater(right), buildSide, joinType, condition) :: Nil
170172 case _ => Nil
171173 }
@@ -174,10 +176,10 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
174176 object CartesianProduct extends Strategy {
175177 def apply (plan : LogicalPlan ): Seq [SparkPlan ] = plan match {
176178 case logical.Join (left, right, _, None ) =>
177- execution.CartesianProduct (planLater(left), planLater(right)) :: Nil
179+ execution.join. CartesianProduct (planLater(left), planLater(right)) :: Nil
178180 case logical.Join (left, right, Inner , Some (condition)) =>
179181 execution.Filter (condition,
180- execution.CartesianProduct (planLater(left), planLater(right))) :: Nil
182+ execution.join. CartesianProduct (planLater(left), planLater(right))) :: Nil
181183 case _ => Nil
182184 }
183185 }
0 commit comments