Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ class VeloxTestSettings extends BackendTestSettings {
enableSuite[GlutenDataSourceV2MetricsSuite]
enableSuite[GlutenDataSourceV2OptionSuite]
enableSuite[GlutenDataSourceV2UtilsSuite]
// TODO: 4.x enableSuite[GlutenGroupBasedUpdateTableSuite] // 1 failure
enableSuite[GlutenGroupBasedUpdateTableSuite]
// Velox assert_not_null throws VeloxUserError instead of SparkRuntimeException
.exclude("update with NOT NULL checks")
Comment on lines +265 to +267
enableSuite[GlutenMergeIntoDataFrameSuite]
enableSuite[GlutenProcedureSuite]
enableSuite[GlutenPushablePredicateSuite]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,34 @@
*/
package org.apache.spark.sql.connector

import org.apache.spark.SparkException
import org.apache.spark.sql.GlutenSQLTestsTrait

class GlutenGroupBasedUpdateTableSuite
extends GroupBasedUpdateTableSuite
with GlutenSQLTestsTrait {}
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")))
}

testGluten("update with NOT NULL 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" }
|""".stripMargin
)

assertNotNullViolation {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we override Spark's checkError in this test suite?

@zml1206 zml1206 Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. We tried overriding checkError, but this case fails before the helper is invoked: the upstream test uses intercept[SparkRuntimeException], while Velox wraps the native NOT NULL violation in a SparkException.
Therefore, unlike the GlutenSimpleSQLViewSuite case, overriding the error assertion helper cannot handle this difference.

sql(s"UPDATE $tableNameAsString SET s = named_struct('n_i', null, 'n_l', -1L) WHERE pk = 1")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ class VeloxTestSettings extends BackendTestSettings {
enableSuite[GlutenDataSourceV2MetricsSuite]
enableSuite[GlutenDataSourceV2OptionSuite]
enableSuite[GlutenDataSourceV2UtilsSuite]
// TODO: 4.x enableSuite[GlutenGroupBasedUpdateTableSuite] // 1 failure
enableSuite[GlutenGroupBasedUpdateTableSuite]
// Velox assert_not_null throws VeloxUserError instead of SparkRuntimeException
.exclude("update with NOT NULL checks")
Comment on lines +275 to +277
enableSuite[GlutenMergeIntoDataFrameSuite]
enableSuite[GlutenProcedureSuite]
enableSuite[GlutenPushablePredicateSuite]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,34 @@
*/
package org.apache.spark.sql.connector

import org.apache.spark.SparkException
import org.apache.spark.sql.GlutenSQLTestsTrait

class GlutenGroupBasedUpdateTableSuite
extends GroupBasedUpdateTableSuite
with GlutenSQLTestsTrait {}
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")))
}

testGluten("update with NOT NULL 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" }
|""".stripMargin
)

assertNotNullViolation {
sql(s"UPDATE $tableNameAsString SET s = named_struct('n_i', null, 'n_l', -1L) WHERE pk = 1")
}
}
}
Loading