ulysses-you commented on a change in pull request #32550:
URL: https://github.com/apache/spark/pull/32550#discussion_r638891754
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala
##########
@@ -1707,4 +1707,50 @@ class AdaptiveQueryExecSuite
}
}
}
+
+ test("SPARK-35264: Support AQE side shuffled hash join formula") {
+ withTable("t1", "t2") {
+ def checkJoinStrategy(shouldShuffleHashJoin: Boolean): Unit = {
+ val (origin1, adaptive1) = runAdaptiveAndVerifyResult(
+ "SELECT t1.c1, t2.c1 FROM t1 JOIN t2 ON t1.c1 = t2.c1")
+ assert(findTopLevelSortMergeJoin(origin1).size === 1)
+ if (shouldShuffleHashJoin) {
+ val shj = findTopLevelShuffledHashJoin(adaptive1)
+ assert(shj.size === 1)
+ assert(shj.head.buildSide == BuildRight)
+ } else {
+ assert(findTopLevelSortMergeJoin(adaptive1).size === 1)
+ }
+
+ // 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)
+ }
+
+ 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")
+
+ // t1 partition size: [926, 729, 731]
+ // t2 partition size: [318, 120, 0]
+ withSQLConf(SQLConf.SHUFFLE_PARTITIONS.key -> "3",
+ SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+ SQLConf.PREFER_SORTMERGEJOIN.key -> "true") {
+ withSQLConf(SQLConf.ADAPTIVE_SHUFFLE_HASH_JOIN_LOCAL_MAP_THRESHOLD.key
-> "318") {
Review comment:
updated
--
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]