ulysses-you commented on a change in pull request #29749:
URL: https://github.com/apache/spark/pull/29749#discussion_r487818296
##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala
##########
@@ -57,8 +58,19 @@ private[hive] case class HiveSimpleUDF(
lazy val function = funcWrapper.createFunction[UDF]()
@transient
- private lazy val method =
-
function.getResolver.getEvalMethod(children.map(_.dataType.toTypeInfo).asJava)
+ private lazy val method = {
+ // the simple UDF method must be 'evaluate'
+ val methods = function.getClass.getMethods.filter(_.getName == "evaluate")
+ val passedMethod = methods.filter(_.getGenericParameterTypes.length ==
children.length)
+
+ // no matching parameter num for evaluate method
+ if (passedMethod.isEmpty) {
+ throw new NoMatchingMethodException(function.getClass,
+ children.map(_.dataType.toTypeInfo).asJava, methods.toSeq.asJava)
+ }
+ // if there exists many method, we choose the first
+ methods.head
Review comment:
Generally, UDF just has one method of `evaluate`.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]