struct ConstEvaluator<'a> {
can_evaluate: Vec<bool>,
execution_props: &'a ExecutionProps,
input_schema: DFSchema,
input_batch: RecordBatch,
}Expand description
Partially evaluate Exprs so constant subtrees are evaluated at plan time.
Note it does not handle algebraic rewrites such as (a or false)
–> a, which is handled by Simplifier
Fields§
§can_evaluate: Vec<bool>can_evaluate is used during the depth-first-search of the
Expr tree to track if any siblings (or their descendants) were
non evaluatable (e.g. had a column reference or volatile
function)
Specifically, can_evaluate[N] represents the state of
traversal when we are N levels deep in the tree, one entry for
this Expr and each of its parents.
After visiting all siblings if can_evaluate.top() is true, that
means there were no non evaluatable siblings (or their
descendants) so this Expr can be evaluated
execution_props: &'a ExecutionProps§input_schema: DFSchema§input_batch: RecordBatchImplementations§
Source§impl<'a> ConstEvaluator<'a>
impl<'a> ConstEvaluator<'a>
Sourcepub fn try_new(execution_props: &'a ExecutionProps) -> Result<Self>
pub fn try_new(execution_props: &'a ExecutionProps) -> Result<Self>
Create a new ConstantEvaluator. Session constants (such as
the time for now() are taken from the passed
execution_props.
Sourcefn volatility_ok(volatility: Volatility) -> bool
fn volatility_ok(volatility: Volatility) -> bool
Can a function of the specified volatility be evaluated?
Sourcefn can_evaluate(expr: &Expr) -> bool
fn can_evaluate(expr: &Expr) -> bool
Can the expression be evaluated at plan time, (assuming all of its children can also be evaluated)?
Sourcepub(crate) fn evaluate_to_scalar(&mut self, expr: Expr) -> ConstSimplifyResult
pub(crate) fn evaluate_to_scalar(&mut self, expr: Expr) -> ConstSimplifyResult
Internal helper to evaluates an Expr
Trait Implementations§
Source§impl TreeNodeRewriter for ConstEvaluator<'_>
impl TreeNodeRewriter for ConstEvaluator<'_>
Auto Trait Implementations§
impl<'a> Freeze for ConstEvaluator<'a>
impl<'a> !RefUnwindSafe for ConstEvaluator<'a>
impl<'a> Send for ConstEvaluator<'a>
impl<'a> Sync for ConstEvaluator<'a>
impl<'a> Unpin for ConstEvaluator<'a>
impl<'a> !UnwindSafe for ConstEvaluator<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more