turboFei commented on a change in pull request #26339:
URL: https://github.com/apache/spark/pull/26339#discussion_r421966564



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/sources/PartitionedWriteSuite.scala
##########
@@ -157,3 +161,49 @@ class PartitionedWriteSuite extends QueryTest with 
SharedSparkSession {
     }
   }
 }
+
+private class DetectDynamicSpeculationCommitProtocol(
+    jobId: String,
+    path: String,
+    dynamicPartitionOverwrite: Boolean)
+  extends HadoopMapReduceCommitProtocol(jobId, path, 
dynamicPartitionOverwrite) {
+
+  override def commitTask(taskContext: TaskAttemptContext): TaskCommitMessage 
= {
+    if (dynamicPartitionOverwrite) {
+      val partitionPathSet = dynamicStagingTaskFiles
+        .map(taskFile => getDynamicPartitionPath(taskFile, taskContext))
+        .map(_.toUri.getPath.stripPrefix(stagingDir.toUri.getPath +
+          Path.SEPARATOR))
+      assert(partitionPathSet.equals(partitionPaths))
+    }
+    super.commitTask(taskContext)
+  }
+}
+
+class PartitionedSpeculateWriteSuite extends QueryTest with SharedSparkSession 
{
+  import testImplicits._
+
+  override def sparkConf(): SparkConf = {
+    super.sparkConf
+      .set(config.SPECULATION_MULTIPLIER, 0.0)
+      .set(config.SPECULATION_QUANTILE, 0.5)
+      .set(config.SPECULATION_ENABLED, true)
+  }
+
+  test("SPARK-27194 SPARK-29302: Fix the issue that for dynamic partition 
overwrite, a " +
+    "task would conflict with its speculative task") {
+    withSQLConf(SQLConf.PARTITION_OVERWRITE_MODE.key -> 
PartitionOverwriteMode.DYNAMIC.toString,
+      SQLConf.FILE_COMMIT_PROTOCOL_CLASS.key ->
+        classOf[DetectDynamicSpeculationCommitProtocol].getName) {
+      withTable("t") {

Review comment:
       This jobId is an UUID.
   So I can not get its value before running query.




----------------------------------------------------------------
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]

Reply via email to