sunchao commented on a change in pull request #32082:
URL: https://github.com/apache/spark/pull/32082#discussion_r614262615



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -2107,6 +2177,29 @@ class Analyzer(override val catalogManager: 
CatalogManager)
             }
         }
     }
+
+    /**
+     * Check if the input `fn` implements the given `methodName`. If 
`inputType` is set, it also
+     * tries to match it against the declared parameter types.
+     */
+    private def findMethod(
+        fn: BoundFunction,
+        methodName: String,
+        inputTypeOpt: Option[Seq[DataType]] = None): Option[Method] = {
+      val cls = fn.getClass
+      inputTypeOpt match {
+        case Some(inputType) =>
+          try {
+            val argClasses = inputType.map(ScalaReflection.dataTypeJavaClass)
+            Some(cls.getDeclaredMethod(methodName, argClasses: _*))
+          } catch {
+            case _: NoSuchMethodException =>
+              None
+          }
+        case None =>
+          cls.getDeclaredMethods.find(_.getName == methodName)

Review comment:
       Hmm sorry not sure what you mean. The case when arg types are known is 
handled above. This is for `AggregateFunction.update` where we just check if 
the method is overridden: due to type erasure we can't do an exact match with 
argument types.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -2107,6 +2177,29 @@ class Analyzer(override val catalogManager: 
CatalogManager)
             }
         }
     }
+
+    /**
+     * Check if the input `fn` implements the given `methodName`. If 
`inputType` is set, it also
+     * tries to match it against the declared parameter types.
+     */
+    private def findMethod(
+        fn: BoundFunction,
+        methodName: String,
+        inputTypeOpt: Option[Seq[DataType]] = None): Option[Method] = {
+      val cls = fn.getClass
+      inputTypeOpt match {
+        case Some(inputType) =>
+          try {
+            val argClasses = inputType.map(ScalaReflection.dataTypeJavaClass)
+            Some(cls.getDeclaredMethod(methodName, argClasses: _*))
+          } catch {
+            case _: NoSuchMethodException =>
+              None
+          }
+        case None =>
+          cls.getDeclaredMethods.find(_.getName == methodName)

Review comment:
       Hmm sorry not sure what you mean. The case when arg types are known is 
handled above (including the 0-arg case). This is for 
`AggregateFunction.update` where we just check if the method is overridden: due 
to type erasure we can't do an exact match with argument types.




-- 
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]

Reply via email to