cloud-fan commented on a change in pull request #29797:
URL: https://github.com/apache/spark/pull/29797#discussion_r503331435
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala
##########
@@ -1258,4 +1264,67 @@ class AdaptiveQueryExecSuite
}
}
}
+
+ test("SPARK-32932: Do not use local shuffle reader at final stage on write
command") {
+ withSQLConf(SQLConf.PARTITION_OVERWRITE_MODE.key ->
PartitionOverwriteMode.DYNAMIC.toString,
+ SQLConf.SHUFFLE_PARTITIONS.key -> "5",
+ SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true") {
+ val data = for (
+ i <- 1L to 10L;
+ j <- 1L to 3L
+ ) yield (i, j)
+
+ val df = data.toDF("i", "j").repartition($"j")
+ var noLocalReader: Boolean = false
+ val listener = new QueryExecutionListener {
+ override def onSuccess(funcName: String, qe: QueryExecution,
durationNs: Long): Unit = {
+ qe.executedPlan match {
+ case plan@(_: DataWritingCommandExec | _: V2TableWriteExec) =>
+
assert(plan.asInstanceOf[UnaryExecNode].child.isInstanceOf[AdaptiveSparkPlanExec])
+ noLocalReader = collect(plan) {
+ case exec: CustomShuffleReaderExec if exec.isLocalReader =>
exec
+ }.isEmpty
+ case _ => // ignore other events
+ }
+ }
+ override def onFailure(funcName: String, qe: QueryExecution,
+ exception: Exception): Unit = {}
+ }
+ spark.listenerManager.register(listener)
+
+ withTable("t") {
+ df.write.partitionBy("j").saveAsTable("t")
+ sparkContext.listenerBus.waitUntilEmpty()
+ assert(noLocalReader)
+ noLocalReader = false
+ }
+
+ // Test DataSource v2
+ withTempPath { f =>
+ val path = f.getCanonicalPath
+ val format = classOf[V2Source].getName
Review comment:
Can we just use `NoopDataSource`?
----------------------------------------------------------------
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]