Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14426
  
    Hi, @watermen . You can try that like this.
    ```scala
    scala> spark.range(1000000000).createOrReplaceTempView("t1")
    scala> spark.range(1000000000).createOrReplaceTempView("t2")
    scala> spark.range(1000000000).createOrReplaceTempView("t3")
    scala> sql("SELECT * FROM t1 JOIN t2 ON t1.id = t2.id JOIN t3 ON t1.id = 
t3.id").explain
    == Physical Plan ==
    *SortMergeJoin [id#0L], [id#8L], Inner
    :- *SortMergeJoin [id#0L], [id#4L], Inner
    :  :- *Sort [id#0L ASC], false, 0
    :  :  +- Exchange hashpartitioning(id#0L, 200)
    :  :     +- *Range (0, 1000000000, splits=8)
    :  +- *Sort [id#4L ASC], false, 0
    :     +- ReusedExchange [id#4L], Exchange hashpartitioning(id#0L, 200)
    +- *Sort [id#8L ASC], false, 0
       +- ReusedExchange [id#8L], Exchange hashpartitioning(id#0L, 200)
    
    scala> sql("SELECT /*+ MAPJOIN(t1) */ * FROM t1 JOIN t2 ON t1.id = t2.id 
JOIN t3 ON t1.id = t3.id").explain
    == Physical Plan ==
    *SortMergeJoin [id#0L], [id#8L], Inner
    :- *Sort [id#0L ASC], false, 0
    :  +- Exchange hashpartitioning(id#0L, 200)
    :     +- *BroadcastHashJoin [id#0L], [id#4L], Inner, BuildLeft
    :        :- BroadcastExchange HashedRelationBroadcastMode(List(input[0, 
bigint, false]))
    :        :  +- *Range (0, 1000000000, splits=8)
    :        +- *Range (0, 1000000000, splits=8)
    +- *Sort [id#8L ASC], false, 0
       +- Exchange hashpartitioning(id#8L, 200)
          +- *Range (0, 1000000000, splits=8)
    
    scala> sql("SELECT /*+ MAPJOIN(t2) */ * FROM t1 JOIN t2 ON t1.id = t2.id 
JOIN t3 ON t1.id = t3.id").explain
    == Physical Plan ==
    *SortMergeJoin [id#0L], [id#8L], Inner
    :- *Sort [id#0L ASC], false, 0
    :  +- Exchange hashpartitioning(id#0L, 200)
    :     +- *BroadcastHashJoin [id#0L], [id#4L], Inner, BuildRight
    :        :- *Range (0, 1000000000, splits=8)
    :        +- BroadcastExchange HashedRelationBroadcastMode(List(input[0, 
bigint, false]))
    :           +- *Range (0, 1000000000, splits=8)
    +- *Sort [id#8L ASC], false, 0
       +- Exchange hashpartitioning(id#8L, 200)
          +- *Range (0, 1000000000, splits=8)
    
    scala> sql("SELECT /*+ MAPJOIN(t3) */ * FROM t1 JOIN t2 ON t1.id = t2.id 
JOIN t3 ON t1.id = t3.id").explain
    == Physical Plan ==
    *BroadcastHashJoin [id#0L], [id#8L], Inner, BuildRight
    :- *SortMergeJoin [id#0L], [id#4L], Inner
    :  :- *Sort [id#0L ASC], false, 0
    :  :  +- Exchange hashpartitioning(id#0L, 200)
    :  :     +- *Range (0, 1000000000, splits=8)
    :  +- *Sort [id#4L ASC], false, 0
    :     +- ReusedExchange [id#4L], Exchange hashpartitioning(id#0L, 200)
    +- BroadcastExchange HashedRelationBroadcastMode(List(input[0, bigint, 
false]))
       +- *Range (0, 1000000000, splits=8)
    ```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to