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 2020/09/14 10:44:16 UTC
[GitHub] [spark] ulysses-you commented on a change in pull request #29749: [SPARK-32877][SQL] Fix Hive UDF not support decimal type in complex type
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org