zml1206 commented on code in PR #12493:
URL: https://github.com/apache/gluten/pull/12493#discussion_r3575424664
##########
gluten-ut/spark40/src/test/scala/org/apache/spark/sql/connector/GlutenGroupBasedUpdateTableSuite.scala:
##########
@@ -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 {
Review Comment:
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.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]