pub trait Expression:
Debug
+ Sync
+ Send {
// Required methods
fn return_type(&self) -> DataType;
fn eval_row<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 OwnedRow,
) -> Pin<Box<dyn Future<Output = Result<Datum>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn eval<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 DataChunk,
) -> Pin<Box<dyn Future<Output = Result<ArrayRef>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn eval_v2<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 DataChunk,
) -> Pin<Box<dyn Future<Output = Result<ValueImpl>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn eval_const(&self) -> Result<Datum> { ... }
fn input_ref_index(&self) -> Option<usize> { ... }
}
Expand description
Interface of an expression.
There’re two functions to evaluate an expression: eval
and eval_v2
, exactly one of them
should be implemented. Prefer calling and implementing eval_v2
instead of eval
if possible,
to gain the performance benefit of scalar expression.
Required Methods§
sourcefn return_type(&self) -> DataType
fn return_type(&self) -> DataType
Get the return data type.
sourcefn eval_row<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 OwnedRow,
) -> Pin<Box<dyn Future<Output = Result<Datum>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn eval_row<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 OwnedRow,
) -> Pin<Box<dyn Future<Output = Result<Datum>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Evaluate the expression in row-based execution. Returns a nullable scalar.
Provided Methods§
sourcefn eval<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 DataChunk,
) -> Pin<Box<dyn Future<Output = Result<ArrayRef>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn eval<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 DataChunk,
) -> Pin<Box<dyn Future<Output = Result<ArrayRef>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Evaluate the expression in vectorized execution. Returns an array.
The default implementation calls eval_v2
and always converts the result to an array.
sourcefn eval_v2<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 DataChunk,
) -> Pin<Box<dyn Future<Output = Result<ValueImpl>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn eval_v2<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 DataChunk,
) -> Pin<Box<dyn Future<Output = Result<ValueImpl>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Evaluate the expression in vectorized execution. Returns a value that can be either an array, or a scalar if all values in the array are the same.
The default implementation calls eval
and puts the result into the Array
variant.
sourcefn eval_const(&self) -> Result<Datum>
fn eval_const(&self) -> Result<Datum>
Evaluate if the expression is constant.
sourcefn input_ref_index(&self) -> Option<usize>
fn input_ref_index(&self) -> Option<usize>
Get the index if the expression is an InputRef
.