-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-23582][SQL] StaticInvoke should support interpreted execution #20753
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 1 commit
9fea286
76c61ad
80579c5
d02e926
b1f08c1
7d66bb9
c66e452
1b3ea29
7279557
0530dcc
0c61e60
984cee7
7b30c30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,20 +222,31 @@ case class StaticInvoke( | |
| override def nullable: Boolean = needNullCheck || returnNullable | ||
| override def children: Seq[Expression] = arguments | ||
|
|
||
|
|
||
|
|
||
| override def eval(input: InternalRow): Any = { | ||
| if (staticObject == null) { | ||
| throw new RuntimeException("The static class cannot be null.") | ||
| val args = arguments.map(e => e.eval(input).asInstanceOf[Object]) | ||
| val argClasses = CallMethodViaReflection.expressionJavaClasses(arguments) | ||
| val cls = if (staticObject.getName == objectName) { | ||
| staticObject | ||
| } else { | ||
| Utils.classForName(objectName) | ||
| } | ||
| val method = cls.getDeclaredMethod(functionName, argClasses : _*) | ||
| if (needNullCheck && args.exists(_ == null)) { | ||
| // return null if one of arguments is null | ||
| null | ||
| } else { | ||
| val ret = method.invoke(null, args: _*) | ||
|
|
||
| val parmTypes = arguments.map(e => | ||
| CallMethodViaReflection.typeMapping.getOrElse(e.dataType, | ||
| Seq(e.dataType.asInstanceOf[ObjectType].cls))(0)) | ||
| val parms = arguments.map(e => e.eval(input).asInstanceOf[Object]) | ||
| val method = staticObject.getDeclaredMethod(functionName, parmTypes : _*) | ||
| val ret = method.invoke(null, parms : _*) | ||
| val retClass = CallMethodViaReflection.typeMapping.getOrElse(dataType, | ||
| Seq(dataType.asInstanceOf[ObjectType].cls))(0) | ||
| retClass.cast(ret) | ||
| if (CodeGenerator.defaultValue(dataType) == "null") { | ||
| ret | ||
| } else { | ||
| // cast a primitive value using Boxed class | ||
| val boxedClass = CallMethodViaReflection.typeBoxedJavaMapping(dataType) | ||
|
||
| boxedClass.cast(ret) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above should be in
CallMethodViaReflectionorCodeGenerator?