Skip to content

Commit

Permalink
Avoid calling statistics on plans if auto join conversion is disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
concretevitamin committed Jul 29, 2014
1 parent 8bd2816 commit 16fc60a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ abstract class LogicalPlan extends QueryPlan[LogicalPlan] {

// TODO: handle overflow?
/**
* Estimates of various statistics. The default estimation logic simply sums up the corresponding
* statistic produced by the children. To override this behavior, override `statistics` and
* assign it a overriden version of `Statistics`.
* Estimates of various statistics. The default estimation logic simply lazily multiplies the
* corresponding statistic produced by the children. To override this behavior, override
* `statistics` and assign it an overriden version of `Statistics`.
*
* '''NOTE''': concrete and/or overriden versions of statistics fields should pay attention to the
* performance of the implementations. The reason is that estimations might get triggered in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
* side in a [[execution.ShuffledHashJoin]].
*/
object HashJoin extends Strategy with PredicateHelper {
private[this] def broadcastHashJoin(
private[this] def makeBroadcastHashJoin(
leftKeys: Seq[Expression],
rightKeys: Seq[Expression],
left: LogicalPlan,
Expand All @@ -72,12 +72,14 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {

def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
case ExtractEquiJoinKeys(Inner, leftKeys, rightKeys, condition, left, right)
if right.statistics.sizeInBytes <= sqlContext.autoConvertJoinSize =>
broadcastHashJoin(leftKeys, rightKeys, left, right, condition, BuildRight)
if sqlContext.autoConvertJoinSize > 0 &&
right.statistics.sizeInBytes <= sqlContext.autoConvertJoinSize =>
makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, BuildRight)

case ExtractEquiJoinKeys(Inner, leftKeys, rightKeys, condition, left, right)
if left.statistics.sizeInBytes <= sqlContext.autoConvertJoinSize =>
broadcastHashJoin(leftKeys, rightKeys, left, right, condition, BuildLeft)
if sqlContext.autoConvertJoinSize > 0 &&
left.statistics.sizeInBytes <= sqlContext.autoConvertJoinSize =>
makeBroadcastHashJoin(leftKeys, rightKeys, left, right, condition, BuildLeft)

case ExtractEquiJoinKeys(Inner, leftKeys, rightKeys, condition, left, right) =>
val buildSide =
Expand Down

0 comments on commit 16fc60a

Please sign in to comment.