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

    https://github.com/apache/spark/pull/11403#discussion_r55453649
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala 
---
    @@ -1318,6 +1318,34 @@ class DataFrameSuite extends QueryTest with 
SharedSQLContext {
     
       }
     
    +  test("reuse exchange") {
    +    withSQLConf("spark.sql.autoBroadcastJoinThreshold" -> "2") {
    +      val df = sqlContext.range(100)
    +      val join = df.join(df, "id")
    +      val plan = join.queryExecution.executedPlan
    +      checkAnswer(join, df)
    +      assert(
    +        join.queryExecution.executedPlan.collect { case e: ShuffleExchange 
=> true }.size === 1)
    +      assert(join.queryExecution.executedPlan.collect { case e: 
ReusedExchange => true }.size === 1)
    +      val broadcasted = broadcast(join)
    +      val join2 = join.join(broadcasted, "id").join(broadcasted, "id")
    +      checkAnswer(join2, df)
    +      assert(
    +        join2.queryExecution.executedPlan.collect { case e: 
ShuffleExchange => true }.size === 1)
    +      assert(
    +        join2.queryExecution.executedPlan.collect { case e: 
BroadcastExchange => true }.size === 1)
    +      assert(
    +        join2.queryExecution.executedPlan.collect { case e: ReusedExchange 
=> true }.size === 4)
    +    }
    +  }
    +
    +  test("same result on aggregate") {
    --- End diff --
    
    I almost suggested that it would be nice to have a test to handle the case 
where `sameResult` is false, but if we were to mess that up then we'd catch it 
pretty quickly via other test failures.


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