MaxGekk commented on code in PR #41599:
URL: https://github.com/apache/spark/pull/41599#discussion_r1233214805
##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala:
##########
@@ -396,20 +396,42 @@ class QueryExecutionErrorsSuite
sqlState = "22023")
}
+ test("FAILED_EXECUTE_UDF: execute user defined function with registered
UDF") {
+ val luckyCharOfWord = udf { (word: String, index: Int) => {
+ word.substring(index, index + 1)
+ }}
+ spark.udf.register("luckyCharOfWord", luckyCharOfWord)
+
+ val e = intercept[SparkException] {
+ Seq(("Jacek", 5), ("Agata", 5), ("Sweet", 6))
+ .toDF("word", "index")
+ .createOrReplaceTempView("words")
+ spark.sql("select luckyCharOfWord(word, index) from words").collect()
+ }
+ assert(e.getCause.isInstanceOf[SparkException])
+
+ checkError(
+ exception = e.getCause.asInstanceOf[SparkException],
+ errorClass = "FAILED_EXECUTE_UDF",
+ parameters = Map(
+ "functionName" -> "luckyCharOfWord
\\(QueryExecutionErrorsSuite\\$\\$Lambda\\$\\d+/\\w+\\)",
Review Comment:
Could you follow our convention for ids and quote the function name by
`toSQLId`, please.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -207,12 +207,12 @@ private[sql] object QueryExecutionErrors extends
QueryErrorsBase {
messageParameters = Map("typeName" -> (dataType + failure)))
}
- def failedExecuteUserDefinedFunctionError(funcCls: String, inputTypes:
String,
+ def failedExecuteUserDefinedFunctionError(functionName: String, inputTypes:
String,
outputType: String, e: Throwable): Throwable = {
new SparkException(
errorClass = "FAILED_EXECUTE_UDF",
messageParameters = Map(
- "functionName" -> funcCls,
+ "functionName" -> functionName,
Review Comment:
Please, quote the function name as you are here:
```suggestion
"functionName" -> toSQLId(functionName),
```
--
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]