cloud-fan commented on a change in pull request #32391:
URL: https://github.com/apache/spark/pull/32391#discussion_r623611602



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala
##########
@@ -1606,4 +1606,52 @@ class AdaptiveQueryExecSuite
       }
     }
   }
+
+  test("SPARK-35264: Support AQE side broadcastJoin threshold") {
+    withTempView("t1", "t2") {
+      def checkJoinStrategy(adaptiveJoinStrategy: String): Unit = {
+        withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1") {
+          val (origin1, adaptive1) = runAdaptiveAndVerifyResult(
+            "SELECT t1.c1, t2.c1 FROM t1 JOIN t2 ON t1.c1 = t2.c1")
+          assert(findTopLevelSortMergeJoin(origin1).size == 1)
+          adaptiveJoinStrategy match {
+            case "BHJ" =>
+              assert(findTopLevelBroadcastHashJoin(adaptive1).size == 1)
+            case "SHJ" =>
+              assert(findTopLevelShuffledHashJoin(adaptive1).size == 1)
+            case "SMJ" =>
+              assert(findTopLevelSortMergeJoin(adaptive1).size == 1)
+            case _ =>
+              throw new IllegalArgumentException(s"Not support strategy: 
$adaptiveJoinStrategy")
+          }
+
+          // respect user specified join hint
+          val (origin2, adaptive2) = runAdaptiveAndVerifyResult(
+            "SELECT /*+ MERGE(t1) */ t1.c1, t2.c1 FROM t1 JOIN t2 ON t1.c1 = 
t2.c1")
+          assert(findTopLevelSortMergeJoin(origin2).size == 1)
+          assert(findTopLevelSortMergeJoin(adaptive2).size == 1)
+        }
+      }
+
+      // t1: 1600 bytes
+      // t2: 160 bytes
+      spark.sparkContext.parallelize(
+        (1 to 100).map(i => TestData(i, i.toString)), 10)
+        .toDF("c1", "c2").createOrReplaceTempView("t1")
+      spark.sparkContext.parallelize(
+        (1 to 10).map(i => TestData(i, i.toString)), 5)
+        .toDF("c1", "c2").createOrReplaceTempView("t2")
+
+      Seq("" -> "", SQLConf.ADAPTIVE_AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1")

Review comment:
       it's simpler to write
   ```
   checkJoinStrategy("SMJ")
   withSQLConf(SQLConf.ADAPTIVE_AUTO_BROADCASTJOIN_THRESHOLD ...) {
     checkJoinStrategy("SMJ")
   } 
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to