This is an automated email from the ASF dual-hosted git repository.
zhztheplayer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git
The following commit(s) were added to refs/heads/main by this push:
new ed8306e693 [GLUTEN-12743][VL] Synchronize the aborted Delta statistics
write test (#13705)
ed8306e693 is described below
commit ed8306e6939b2d9722e6336e8f7a6edca0a3e8c0
Author: Felipe Pessoto <[email protected]>
AuthorDate: Mon Nov 30 10:57:53 2026 -0800
[GLUTEN-12743][VL] Synchronize the aborted Delta statistics write test
(#13705)
Keep the valid writer active after its first native statistics batch.
Release the invalid partition only then, and verify Spark canceled the valid
task without weakening the cleanup and recovery checks.
---
.../sql/delta/GlutenDeltaStatsLifecycleSuite.scala | 67 ++++++++++++++++++----
1 file changed, 57 insertions(+), 10 deletions(-)
diff --git
a/backends-velox/src-delta33/test/scala/org/apache/spark/sql/delta/GlutenDeltaStatsLifecycleSuite.scala
b/backends-velox/src-delta33/test/scala/org/apache/spark/sql/delta/GlutenDeltaStatsLifecycleSuite.scala
index 282022b873..c0cd8a308c 100644
---
a/backends-velox/src-delta33/test/scala/org/apache/spark/sql/delta/GlutenDeltaStatsLifecycleSuite.scala
+++
b/backends-velox/src-delta33/test/scala/org/apache/spark/sql/delta/GlutenDeltaStatsLifecycleSuite.scala
@@ -23,7 +23,7 @@ import
org.apache.gluten.memory.arrow.alloc.ArrowBufferAllocators
import org.apache.gluten.vectorized.RefCountedArrowColumnVector
import org.apache.spark.{SparkConf, TaskContext}
-import org.apache.spark.sql.{GlutenQueryTest, Row, SparkSession}
+import org.apache.spark.sql.{DataFrame, GlutenQueryTest, Row, SparkSession}
import org.apache.spark.sql.catalyst.expressions.ScalaUDF
import org.apache.spark.sql.catalyst.plans.logical.Aggregate
import org.apache.spark.sql.delta.actions.Metadata
@@ -38,9 +38,10 @@ import org.apache.spark.task.{TaskResourceRegistry,
TaskResources}
import org.apache.arrow.vector.BigIntVector
import org.apache.hadoop.fs.Path
+import org.scalatest.concurrent.Eventually
import java.lang.management.ManagementFactory
-import java.util.concurrent.{ConcurrentLinkedQueue, CountDownLatch,
ExecutionException, TimeUnit}
+import java.util.concurrent.{CompletableFuture, ConcurrentHashMap,
ConcurrentLinkedQueue, CountDownLatch, ExecutionException, TimeUnit}
import java.util.concurrent.atomic.{AtomicBoolean, AtomicReference}
import scala.collection.JavaConverters._
@@ -116,15 +117,19 @@ class GlutenDeltaStatsLifecycleSuite extends
GlutenQueryTest with SharedSparkSes
DeltaLog.forTable(spark, path).startTransaction()
.commit(Seq(Metadata(schemaString = schema.json)),
DeltaOperations.ManualUpdate)
spark.read.format("delta").load(path).write.format("delta").mode("overwrite").save(path)
- val invalid = spark.createDataFrame(Seq(Row(1L), Row(null)).asJava,
schema.asNullable)
- withNativeStatistics(path) {
- val failure = intercept[Exception] {
- invalid.write.format("delta").mode("append").save(path)
+ withSQLConf(GlutenConfig.COLUMNAR_MAX_BATCH_SIZE.key -> "1") {
+ AbortingDeltaWrite.withInput(spark, path, schema.asNullable) {
+ invalid =>
+ withNativeStatistics(path) {
+ val failure = intercept[Exception] {
+ invalid.write.format("delta").mode("append").save(path)
+ }
+ assert(
+ Iterator.iterate[Throwable](failure)(_.getCause).takeWhile(_
!= null)
+ .exists(_.isInstanceOf[InvariantViolationException]),
+ failure.toString)
+ }
}
- assert(
- Iterator.iterate[Throwable](failure)(_.getCause).takeWhile(_ !=
null)
- .exists(_.isInstanceOf[InvariantViolationException]),
- failure.toString)
}
assert(spark.read.format("delta").load(path).count() == 0)
withNativeStatistics(path) {
@@ -503,3 +508,45 @@ class GlutenDeltaStatsLifecycleSuite extends
GlutenQueryTest with SharedSparkSes
completionChecks.asScala.foreach(_())
}
}
+
+private object AbortingDeltaWrite extends Eventually {
+ // Local Spark tasks share this registry, not the serialized copies of their
closures.
+ private val writers = new ConcurrentHashMap[String,
CompletableFuture[TaskContext]]()
+
+ def withInput(spark: SparkSession, path: String, schema: StructType)(
+ write: DataFrame => Unit): Unit = {
+ val writer = new CompletableFuture[TaskContext]()
+ writers.put(path, writer)
+ try {
+ val rows = spark.sparkContext.parallelize(Seq(0, 1),
2).flatMap(partitionRows(path, _))
+ write(spark.createDataFrame(rows, schema))
+ assert(writer.get(30, TimeUnit.SECONDS).isInterrupted(), "The valid
writer was not canceled")
+ } finally {
+ writers.remove(path)
+ }
+ }
+
+ private def partitionRows(path: String, partition: Int): Iterator[Row] = {
+ val writer = writers.get(path)
+ if (partition == 0) {
+ Iterator(1L, 2L).map {
+ id =>
+ if (id == 2L) {
+ // With one row per batch, the worker has accepted the first batch
by this point.
+ val context = TaskContext.get()
+ writer.complete(context)
+ eventually(timeout(30.seconds), interval(10.millis)) {
+ assert(
+ context.isInterrupted(),
+ "Timed out waiting for the invalid partition to abort")
+ }
+ context.killTaskIfInterrupted()
+ }
+ Row(id)
+ }
+ } else {
+ writer.get(30, TimeUnit.SECONDS)
+ Iterator.single(Row(null))
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]