You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/04/17 08:33:53 UTC

[GitHub] [spark] MaxGekk commented on a diff in pull request #36220: [SPARK-38727][SQL][TESTS] Test the error class: FAILED_EXECUTE_UDF

MaxGekk commented on code in PR #36220:
URL: https://github.com/apache/spark/pull/36220#discussion_r851722710


##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala:
##########
@@ -388,4 +388,19 @@ class QueryExecutionErrorsSuite extends QueryTest
             |""".stripMargin)
     }
   }
+
+  test("FAILED_EXECUTE_UDF: execute user defined function") {
+    val e1 = intercept[SparkException] {
+      val names = Seq("Jacek", "Agata", "Sweet").toDF("name")
+      val hello = udf { _: String => {
+        throw new SparkException("throw spark exception for udf test")
+      }}
+      names.select(hello($"name")).collect()
+    }
+    assert(e1.getCause.isInstanceOf[SparkException])
+
+    val e2 = e1.getCause.asInstanceOf[SparkException]
+    assert(e2.getErrorClass === "FAILED_EXECUTE_UDF")
+    assert(e2.getMessage.startsWith("Failed to execute user defined function "))

Review Comment:
   Please, compare to the entire error message. A purpose is to document errors in tests.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org