venkata91 commented on a change in pull request #26339: 
[SPARK-27194][SPARK-29302][SQL] Fix the issue that for dynamic partition 
overwrite a task would conflict with its speculative task
URL: https://github.com/apache/spark/pull/26339#discussion_r410825389
 
 

 ##########
 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:
   I was testing it locally, without the fix this test still passes. Can you 
please check once?

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


With regards,
Apache Git Services

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

Reply via email to