import org.apache.spark.sql.catalyst.expressions.BoundReference
import org.apache.spark.sql.types.LongType
val boundRef = BoundReference(ordinal = 0, dataType = LongType, nullable = true)
scala> println(boundRef.toString)
input[0, bigint, true]
import org.apache.spark.sql.catalyst.InternalRow
val row = InternalRow(1L, "hello")
val value = boundRef.eval(row).asInstanceOf[Long]
BoundReference Leaf Expression — Reference to Value in Internal Binary Row
BoundReference
is a leaf expression that evaluates to a value in an internal binary row at a specified position and of a given data type.
BoundReference
takes the following when created:
-
Data type of the value
-
nullable
flag that controls whether the value can benull
or not
You can also create a BoundReference
using Catalyst DSL’s at method.
import org.apache.spark.sql.catalyst.dsl.expressions._
val boundRef = 'hello.string.at(4)
scala> println(boundRef)
input[4, string, true]
Evaluating Expression — eval
Method
eval(input: InternalRow): Any
Note
|
eval is part of Expression Contract for the interpreted (non-code-generated) expression evaluation, i.e. evaluating a Catalyst expression to a JVM object for a given internal binary row.
|
eval
gives the value at position from the input
internal binary row that is of a correct type.
Internally, eval
returns null
if the value at the position is null
.
Otherwise, eval
uses the methods of InternalRow
per the defined data type to access the value.
DataType | InternalRow’s Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
others |
|
Generating Java Source Code (ExprCode) For Code-Generated Expression Evaluation — doGenCode
Method
doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode
Note
|
doGenCode is part of Expression Contract to generate a Java source code (ExprCode) for code-generated expression evaluation.
|
doGenCode
…FIXME