Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/7417#discussion_r35433038
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala ---
@@ -213,10 +213,51 @@ private[sql] abstract class SparkStrategies extends
QueryPlanner[SparkPlan] {
object CartesianProduct extends Strategy {
def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
case logical.Join(left, right, _, None) =>
- execution.joins.CartesianProduct(planLater(left),
planLater(right)) :: Nil
+ // For BroadcastCartesianProduct we will broadcast the small size
plan,
+ // for CartesianProduct we will use the small size plan as
cartesian left rdd.
+ if (right.statistics.sizeInBytes <= left.statistics.sizeInBytes) {
+ if (sqlContext.conf.autoBroadcastJoinThreshold > 0 &&
+ right.statistics.sizeInBytes <=
sqlContext.conf.autoBroadcastJoinThreshold) {
+ execution.joins.BroadcastCartesianProduct(planLater(left),
planLater(right),
+ joins.BuildRight) :: Nil
+ } else {
+ execution.joins.CartesianProduct(planLater(left),
planLater(right),
+ joins.BuildLeft) :: Nil
+ }
+ } else {
+ if (sqlContext.conf.autoBroadcastJoinThreshold > 0 &&
+ left.statistics.sizeInBytes <=
sqlContext.conf.autoBroadcastJoinThreshold) {
+ execution.joins.BroadcastCartesianProduct(planLater(left),
planLater(right),
+ joins.BuildLeft) :: Nil
+ } else {
+ execution.joins.CartesianProduct(planLater(left),
planLater(right),
+ joins.BuildRight) :: Nil
+ }
+ }
case logical.Join(left, right, Inner, Some(condition)) =>
- execution.Filter(condition,
- execution.joins.CartesianProduct(planLater(left),
planLater(right))) :: Nil
+ if (right.statistics.sizeInBytes <= left.statistics.sizeInBytes) {
--- End diff --
This code is almost the same as the code above. I would put it in a method
i.e. ```createCartesianProduct```, and wrap the result in a ```Filter```
operator.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]