|
19 | 19 |
|
20 | 20 | package org.apache.comet.exec |
21 | 21 |
|
| 22 | +import scala.util.Random |
| 23 | + |
22 | 24 | import org.scalactic.source.Position |
23 | 25 | import org.scalatest.Tag |
24 | 26 |
|
25 | 27 | import org.apache.hadoop.fs.Path |
26 | 28 | import org.apache.spark.{Partitioner, SparkConf} |
27 | | -import org.apache.spark.sql.{CometTestBase, DataFrame, Row} |
| 29 | +import org.apache.spark.sql.{CometTestBase, DataFrame, RandomDataGenerator, Row} |
28 | 30 | import org.apache.spark.sql.comet.execution.shuffle.{CometShuffleDependency, CometShuffleExchangeExec, CometShuffleManager} |
29 | 31 | import org.apache.spark.sql.execution.adaptive.{AdaptiveSparkPlanHelper, AQEShuffleReadExec, ShuffleQueryStageExec} |
30 | 32 | import org.apache.spark.sql.execution.exchange.ReusedExchangeExec |
@@ -68,17 +70,35 @@ abstract class CometColumnarShuffleSuite extends CometTestBase with AdaptiveSpar |
68 | 70 |
|
69 | 71 | test("Unsupported types for SinglePartition should fallback to Spark") { |
70 | 72 | checkSparkAnswer(spark.sql(""" |
71 | | - |SELECT |
72 | | - | AVG(null), |
73 | | - | COUNT(null), |
74 | | - | FIRST(null), |
75 | | - | LAST(null), |
76 | | - | MAX(null), |
77 | | - | MIN(null), |
78 | | - | SUM(null) |
| 73 | + |SELECT |
| 74 | + | AVG(null), |
| 75 | + | COUNT(null), |
| 76 | + | FIRST(null), |
| 77 | + | LAST(null), |
| 78 | + | MAX(null), |
| 79 | + | MIN(null), |
| 80 | + | SUM(null) |
79 | 81 | """.stripMargin)) |
80 | 82 | } |
81 | 83 |
|
| 84 | + test("Fallback to Spark for unsupported input besides ordering") { |
| 85 | + val dataGenerator = RandomDataGenerator |
| 86 | + .forType( |
| 87 | + dataType = NullType, |
| 88 | + nullable = true, |
| 89 | + new Random(System.nanoTime()), |
| 90 | + validJulianDatetime = false) |
| 91 | + .get |
| 92 | + |
| 93 | + val schema = new StructType() |
| 94 | + .add("index", IntegerType, nullable = false) |
| 95 | + .add("col", NullType, nullable = true) |
| 96 | + val rdd = |
| 97 | + spark.sparkContext.parallelize((1 to 20).map(i => Row(i, dataGenerator()))) |
| 98 | + val df = spark.createDataFrame(rdd, schema).orderBy("index").coalesce(1) |
| 99 | + checkSparkAnswer(df) |
| 100 | + } |
| 101 | + |
82 | 102 | test("Disable Comet shuffle with AQE coalesce partitions enabled") { |
83 | 103 | Seq(true, false).foreach { coalescePartitionsEnabled => |
84 | 104 | withSQLConf( |
|
0 commit comments