viirya commented on a change in pull request #25108: [SPARK-28321][SQL] 0-args
Java UDF should not be called only once
URL: https://github.com/apache/spark/pull/25108#discussion_r302477487
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/UDFRegistration.scala
##########
@@ -142,14 +142,14 @@ class UDFRegistration private[sql] (functionRegistry:
FunctionRegistry) extends
val anyCast = s".asInstanceOf[UDF$i[$anyTypeArgs]]"
val anyParams = (1 to i).map(_ => "_: Any").mkString(", ")
val version = if (i == 0) "2.3.0" else "1.3.0"
- val funcCall = if (i == 0) "() => func" else "func"
+ val funcCall = if (i == 0) s"() => f$anyCast.call($anyParams)" else
s"f$anyCast.call($anyParams)"
println(s"""
|/**
| * Register a deterministic Java UDF$i instance as user-defined
function (UDF).
| * @since $version
| */
|def register(name: String, f: UDF$i[$extTypeArgs], returnType:
DataType): Unit = {
- | val func = f$anyCast.call($anyParams)
+ | val func = $funcCall
| def builder(e: Seq[Expression]) = if (e.length == $i) {
| ScalaUDF($funcCall, returnType, e, e.map(_ => false), udfName =
Some(name))
Review comment:
Seems like this should be updated? Like `ScalaUDF(func, ...)`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]