CallMethodViaReflection Expression¶
CallMethodViaReflection
is a non-deterministic expression that represents a static method call (in Scala or Java) using reflect
and java_method
standard functions.
CallMethodViaReflection
supports fallback mode for expression code generation.
Creating Instance¶
CallMethodViaReflection
takes the following to be created:
- Children Expressions
CallMethodViaReflection
is created when:
reflect
standard function is used
evalInternal¶
Nondeterministic
evalInternal(
input: InternalRow): Any
evalInternal
is part of the Nondeterministic abstraction.
evalInternal
...FIXME
initializeInternal¶
Nondeterministic
initializeInternal(
partitionIndex: Int): Unit
initializeInternal
is part of the Nondeterministic abstraction.
initializeInternal
...FIXME
Demo¶
import org.apache.spark.sql.catalyst.expressions.CallMethodViaReflection
import org.apache.spark.sql.catalyst.expressions.Literal
val expr = CallMethodViaReflection(
Literal("java.time.LocalDateTime") ::
Literal("now") :: Nil)
scala> println(expr.numberedTreeString)
00 reflect(java.time.LocalDateTime, now, true)
01 :- java.time.LocalDateTime
02 +- now
val q = """SELECT reflect("java.time.LocalDateTime", "now") AS now"""
val plan = spark.sql(q).queryExecution.logical
// CallMethodViaReflection shows itself under "reflect" name
scala> println(plan.numberedTreeString)
00 'Project ['reflect(java.time.LocalDateTime, now) AS now#0]
01 +- OneRowRelation