Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7417#discussion_r38678714
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/CartesianProduct.scala
 ---
    @@ -27,16 +27,27 @@ import org.apache.spark.sql.execution.{BinaryNode, 
SparkPlan}
      * :: DeveloperApi ::
      */
     @DeveloperApi
    -case class CartesianProduct(left: SparkPlan, right: SparkPlan) extends 
BinaryNode {
    +case class CartesianProduct(
    +    left: SparkPlan,
    +    right: SparkPlan,
    +    buildSide: BuildSide) extends BinaryNode {
       override def output: Seq[Attribute] = left.output ++ right.output
     
    +  private val (small, big) = buildSide match {
    +    case BuildRight => (left, right)
    +    case BuildLeft => (right, left)
    +  }
    +
       protected override def doExecute(): RDD[InternalRow] = {
    -    val leftResults = left.execute().map(_.copy())
    -    val rightResults = right.execute().map(_.copy())
    +    val leftResults = small.execute().map(_.copy())
    +    val rightResults = big.execute().map(_.copy())
    --- End diff --
    
    As comment by @zsxwing , the right side will be iterated multiple times by 
CartesianRDD, so it make sense to having small on the right side. We could even 
load all the items on right side into memory as Array, we could do this if each 
partition of `small` could fit in memory. 


---
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]

Reply via email to