This is an automated email from the ASF dual-hosted git repository.
rui-mo 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 01f3c69403 [GLUTEN-13175][VL] Add Spark 4.2 UPDATE NOT NULL test
(#13313)
01f3c69403 is described below
commit 01f3c69403da02a38de15e229a08d6061c80ce6a
Author: Akshay Tayal <[email protected]>
AuthorDate: Tue Oct 20 11:25:48 2026 -0700
[GLUTEN-13175][VL] Add Spark 4.2 UPDATE NOT NULL test (#13313)
---
.../gluten/utils/velox/VeloxTestSettings.scala | 6 ++--
.../GlutenGroupBasedUpdateTableSuite.scala | 14 ++-------
...uite.scala => GlutenUpdateTableSuiteBase.scala} | 34 +++++++++++++++-------
3 files changed, 28 insertions(+), 26 deletions(-)
diff --git
a/gluten-ut/spark42/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
b/gluten-ut/spark42/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
index be6cab7e93..21bda74ea2 100644
---
a/gluten-ut/spark42/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
+++
b/gluten-ut/spark42/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
@@ -336,9 +336,9 @@ class VeloxTestSettings extends BackendTestSettings {
enableSuite[GlutenGroupBasedUpdateTableSuite]
// Velox assert_not_null throws VeloxUserError instead of
SparkRuntimeException
.exclude("update with NOT NULL checks")
- .exclude(
- "update with constraint violation and transactional checks"
- ) // GLUTEN-12569 Spark 4.2 UT enablement (CI-confirmed)
+ // Velox assert_not_null throws VeloxUserError instead of
SparkRuntimeException.
+ // Rewritten in GlutenUpdateTableSuiteBase.
+ .exclude("update with constraint violation and transactional checks")
enableSuite[GlutenMergeIntoDataFrameSuite]
enableSuite[GlutenProcedureSuite]
enableSuite[GlutenPushablePredicateSuite]
diff --git
a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenGroupBasedUpdateTableSuite.scala
b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenGroupBasedUpdateTableSuite.scala
index 4c400fa07a..8488c1bf9b 100644
---
a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenGroupBasedUpdateTableSuite.scala
+++
b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenGroupBasedUpdateTableSuite.scala
@@ -16,22 +16,12 @@
*/
package org.apache.spark.sql.connector
-import org.apache.spark.SparkException
import org.apache.spark.sql.GlutenSQLTestsTrait
class GlutenGroupBasedUpdateTableSuite
extends GroupBasedUpdateTableSuite
- with GlutenSQLTestsTrait {
-
- private def assertNotNullViolation(f: => Unit): Unit = {
- val exception = intercept[SparkException](f)
- val messages = Iterator
- .iterate[Throwable](exception)(_.getCause)
- .takeWhile(_ != null)
- .flatMap(e => Option(e.getMessage))
-
- assert(messages.exists(_.contains("Null value appeared in non-nullable
field")))
- }
+ with GlutenSQLTestsTrait
+ with GlutenUpdateTableSuiteBase {
testGluten("update with NOT NULL checks") {
createAndInitTable(
diff --git
a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenGroupBasedUpdateTableSuite.scala
b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenUpdateTableSuiteBase.scala
similarity index 53%
copy from
gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenGroupBasedUpdateTableSuite.scala
copy to
gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenUpdateTableSuiteBase.scala
index 4c400fa07a..5dc767e102 100644
---
a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenGroupBasedUpdateTableSuite.scala
+++
b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/connector/GlutenUpdateTableSuiteBase.scala
@@ -17,13 +17,17 @@
package org.apache.spark.sql.connector
import org.apache.spark.SparkException
-import org.apache.spark.sql.GlutenSQLTestsTrait
+import org.apache.spark.sql.GlutenSQLTestsBaseTrait
+import org.apache.spark.sql.connector.catalog.Aborted
-class GlutenGroupBasedUpdateTableSuite
- extends GroupBasedUpdateTableSuite
- with GlutenSQLTestsTrait {
+/**
+ * Gluten versions of [[UpdateTableSuiteBase]] tests that expect Spark's
+ * `SparkRuntimeException(NOT_NULL_ASSERT_VIOLATION)`. Velox `assert_not_null`
throws a
+ * `VeloxUserError` instead, which fails the query with a `SparkException`.
+ */
+trait GlutenUpdateTableSuiteBase extends UpdateTableSuiteBase with
GlutenSQLTestsBaseTrait {
- private def assertNotNullViolation(f: => Unit): Unit = {
+ protected def assertNotNullViolation(f: => Unit): Unit = {
val exception = intercept[SparkException](f)
val messages = Iterator
.iterate[Throwable](exception)(_.getCause)
@@ -33,17 +37,25 @@ class GlutenGroupBasedUpdateTableSuite
assert(messages.exists(_.contains("Null value appeared in non-nullable
field")))
}
- testGluten("update with NOT NULL checks") {
+ testGluten("update with constraint violation and transactional checks") {
createAndInitTable(
- "pk INT NOT NULL, s STRUCT<n_i: INT NOT NULL, n_l: LONG>, dep STRING",
- """{ "pk": 1, "s": { "n_i": 1, "n_l": 11 }, "dep": "hr" }
- |{ "pk": 2, "s": { "n_i": 2, "n_l": 22 }, "dep": "software" }
- |{ "pk": 3, "s": { "n_i": 3, "n_l": 33 }, "dep": "hr" }
+ "pk INT NOT NULL, salary INT, dep STRING",
+ """{ "pk": 1, "salary": 100, "dep": "hr" }
+ |{ "pk": 2, "salary": 200, "dep": "software" }
+ |{ "pk": 3, "salary": 300, "dep": "hr" }
|""".stripMargin
)
assertNotNullViolation {
- sql(s"UPDATE $tableNameAsString SET s = named_struct('n_i', null, 'n_l',
-1L) WHERE pk = 1")
+ executeTransaction {
+ sql(s"""UPDATE $tableNameAsString
+ |SET pk = NULL
+ |WHERE dep = 'hr'
+ |""".stripMargin) // NULL violates NOT NULL constraint
+ }
}
+
+ assert(catalog.lastTransaction.currentState == Aborted)
+ assert(catalog.lastTransaction.isClosed)
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]