turboFei 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_r410834586
 
 

 ##########
 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:
   It does pass without this fix.
   Because for the local file system, it would not throw exception.
   But for the distributed file system, it do not allow two task write the same 
file.
   The exception is liked `No lease on inode`.

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