You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/09 14:03:15 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #32084: [SPARK-34980][SQL] Support coalesce partition through union in AQE

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



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala
##########
@@ -1575,4 +1575,51 @@ class AdaptiveQueryExecSuite
       checkNoCoalescePartitions(df.sort($"key"), ENSURE_REQUIREMENTS)
     }
   }
+
+  test("SPARK-34980: Support coalesce partition through union") {
+    def checkResultPartition(
+      df: Dataset[Row], shuffleReaderNumber: Int, partitionNumber: Int): Unit = {
+      df.collect()
+      assert(
+        collect(df.queryExecution.executedPlan) {
+          case s: CustomShuffleReaderExec => s
+        }.size === shuffleReaderNumber
+      )
+      assert(df.rdd.partitions.length === partitionNumber)
+    }
+
+    withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true",
+      SQLConf.COALESCE_PARTITIONS_ENABLED.key -> "true",
+      SQLConf.ADVISORY_PARTITION_SIZE_IN_BYTES.key -> "1048576",
+      SQLConf.COALESCE_PARTITIONS_MIN_PARTITION_NUM.key -> "1",
+      SQLConf.SHUFFLE_PARTITIONS.key -> "10") {
+      val df1 = spark.sparkContext.parallelize(
+        (1 to 10).map(i => TestData(i, i.toString)), 2).toDF()
+      val df2 = spark.sparkContext.parallelize(
+        (1 to 10).map(i => TestData(i, i.toString)), 4).toDF()
+
+      // positive test
+      checkResultPartition(
+        df1.groupBy("key").count().unionAll(df2),
+        1,
+        1 + 4)
+
+      checkResultPartition(
+        df1.groupBy("key").count().unionAll(df2).unionAll(df1),
+        1,
+        1 + 4 + 2)
+
+      checkResultPartition(
+        df1.groupBy("key").count().unionAll(df2).unionAll(df1.groupBy("key").count()),
+        2,
+        1 + 4 + 1)

Review comment:
       +1




-- 
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:
users@infra.apache.org



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