-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-35278][SQL] Invoke should find the method with correct number of parameters #32404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3829aaa
9fc152c
8eed4d1
d03318a
176b103
bfaaf32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -325,11 +325,30 @@ case class Invoke( | |
|
|
||
| @transient lazy val method = targetObject.dataType match { | ||
| case ObjectType(cls) => | ||
| val m = cls.getMethods.find(_.getName == encodedFunctionName) | ||
| if (m.isEmpty) { | ||
| sys.error(s"Couldn't find $encodedFunctionName on $cls") | ||
| } else { | ||
| m | ||
| // Looking with function name + argument classes first. | ||
| try { | ||
| Some(cls.getMethod(encodedFunctionName, argClasses: _*)) | ||
| } catch { | ||
| case _: NoSuchMethodException => | ||
| // For some cases, e.g. arg class is Object, `getMethod` cannot find the method. | ||
| // We look at function name + argument length | ||
| val m = cls.getMethods.filter { m => | ||
| m.getName == encodedFunctionName && m.getParameterCount == arguments.length | ||
| } | ||
| if (m.isEmpty) { | ||
| sys.error(s"Couldn't find $encodedFunctionName on $cls") | ||
| } else if (m.length > 1) { | ||
| // More than one matched method signature. Exclude synthetic one, e.g. generic one. | ||
| val realMethods = m.filter(!_.isSynthetic) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot filter out synthetic ones in L336?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it is possible that there is only one method and it is also a synthetic one. If we filter synthetic ones at L336, we may miss it? |
||
| if (realMethods.length > 1) { | ||
| // Ambiguous case, we don't know which method to choose, just fail it. | ||
| sys.error(s"Found ${realMethods.length} $encodedFunctionName on $cls") | ||
| } else { | ||
| Some(realMethods.head) | ||
| } | ||
| } else { | ||
| Some(m.head) | ||
| } | ||
| } | ||
| case _ => None | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.