ulysses-you commented on code in PR #42003:
URL: https://github.com/apache/spark/pull/42003#discussion_r1272014163
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala:
##########
@@ -874,6 +875,69 @@ class AdaptiveQueryExecSuite
}
}
+ test("SPARK-44426: Optimize adaptive skew join for ExistenceJoin") {
+ withSQLConf(
+ SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+ SQLConf.COALESCE_PARTITIONS_MIN_PARTITION_NUM.key -> "1",
+ SQLConf.SHUFFLE_PARTITIONS.key -> "100",
+ SQLConf.SKEW_JOIN_SKEWED_PARTITION_THRESHOLD.key -> "800",
+ SQLConf.ADVISORY_PARTITION_SIZE_IN_BYTES.key -> "800") {
+ withTempView("skewed", "nonSkewed") {
+ // skewData1
+ spark
+ .range(0, 1000, 1, 10)
+ .select(
+ when('id < 250, 249)
+ .when('id >= 750, 1000)
+ .otherwise('id).as("key1"),
+ 'id as "value1")
+ .createOrReplaceTempView("skewed")
+ // skewData2
+ spark
+ .range(0, 1000, 1, 10)
+ .select(
+ 'id as "key2",
+ 'id as "value2")
+ .createOrReplaceTempView("nonSkewed")
+
+ def checkSkewJoin(
Review Comment:
can we inline this function ? it seems only be used once.
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala:
##########
@@ -874,6 +875,69 @@ class AdaptiveQueryExecSuite
}
}
+ test("SPARK-44426: Optimize adaptive skew join for ExistenceJoin") {
+ withSQLConf(
+ SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+ SQLConf.COALESCE_PARTITIONS_MIN_PARTITION_NUM.key -> "1",
+ SQLConf.SHUFFLE_PARTITIONS.key -> "100",
+ SQLConf.SKEW_JOIN_SKEWED_PARTITION_THRESHOLD.key -> "800",
+ SQLConf.ADVISORY_PARTITION_SIZE_IN_BYTES.key -> "800") {
+ withTempView("skewed", "nonSkewed") {
+ // skewData1
+ spark
+ .range(0, 1000, 1, 10)
+ .select(
+ when('id < 250, 249)
+ .when('id >= 750, 1000)
+ .otherwise('id).as("key1"),
+ 'id as "value1")
+ .createOrReplaceTempView("skewed")
+ // skewData2
+ spark
+ .range(0, 1000, 1, 10)
+ .select(
+ 'id as "key2",
+ 'id as "value2")
+ .createOrReplaceTempView("nonSkewed")
+
+ def checkSkewJoin(
+ joins: Seq[SortMergeJoinExec],
+ leftSkewNum: Int,
+ rightSkewNum: Int): Unit = {
+ assert(joins.size == 1 && joins.last.isSkewJoin)
+ assert(joins.last.left.collect {
+ case r: AQEShuffleReadExec => r
+ }.head.partitionSpecs.collect {
+ case p: PartialReducerPartitionSpec => p.reducerIndex
+ }.distinct.length == leftSkewNum)
Review Comment:
```scala
assert(joins.last.left.exists {
case AQEShuffleReadExec(_, p) if
p.exists(_.isInstanceOf[PartialReducerPartitionSpec]) => true
})
```
We do not really need to check the number of skewed partition spec.
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala:
##########
@@ -874,6 +875,69 @@ class AdaptiveQueryExecSuite
}
}
+ test("SPARK-44426: Optimize adaptive skew join for ExistenceJoin") {
+ withSQLConf(
+ SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+ SQLConf.COALESCE_PARTITIONS_MIN_PARTITION_NUM.key -> "1",
+ SQLConf.SHUFFLE_PARTITIONS.key -> "100",
+ SQLConf.SKEW_JOIN_SKEWED_PARTITION_THRESHOLD.key -> "800",
+ SQLConf.ADVISORY_PARTITION_SIZE_IN_BYTES.key -> "800") {
+ withTempView("skewed", "nonSkewed") {
+ // skewData1
+ spark
+ .range(0, 1000, 1, 10)
+ .select(
+ when('id < 250, 249)
+ .when('id >= 750, 1000)
+ .otherwise('id).as("key1"),
+ 'id as "value1")
+ .createOrReplaceTempView("skewed")
+ // skewData2
Review Comment:
please remove it
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala:
##########
@@ -874,6 +875,69 @@ class AdaptiveQueryExecSuite
}
}
+ test("SPARK-44426: Optimize adaptive skew join for ExistenceJoin") {
+ withSQLConf(
+ SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+ SQLConf.COALESCE_PARTITIONS_MIN_PARTITION_NUM.key -> "1",
+ SQLConf.SHUFFLE_PARTITIONS.key -> "100",
+ SQLConf.SKEW_JOIN_SKEWED_PARTITION_THRESHOLD.key -> "800",
+ SQLConf.ADVISORY_PARTITION_SIZE_IN_BYTES.key -> "800") {
+ withTempView("skewed", "nonSkewed") {
+ // skewData1
+ spark
+ .range(0, 1000, 1, 10)
+ .select(
+ when('id < 250, 249)
Review Comment:
please do not user `'` to represent the symbol which is deprecated. You can
use `$"id"` instead
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala:
##########
@@ -874,6 +875,69 @@ class AdaptiveQueryExecSuite
}
}
+ test("SPARK-44426: Optimize adaptive skew join for ExistenceJoin") {
+ withSQLConf(
+ SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+ SQLConf.COALESCE_PARTITIONS_MIN_PARTITION_NUM.key -> "1",
+ SQLConf.SHUFFLE_PARTITIONS.key -> "100",
+ SQLConf.SKEW_JOIN_SKEWED_PARTITION_THRESHOLD.key -> "800",
+ SQLConf.ADVISORY_PARTITION_SIZE_IN_BYTES.key -> "800") {
+ withTempView("skewed", "nonSkewed") {
+ // skewData1
Review Comment:
please remove it
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]