Struct mz_expr::OptimizedMirRelationExpr
source · pub struct OptimizedMirRelationExpr(pub MirRelationExpr);
Expand description
A MirRelationExpr
that claims to have been optimized, e.g., by an
transform::Optimizer
.
Tuple Fields§
§0: MirRelationExpr
Implementations§
source§impl OptimizedMirRelationExpr
impl OptimizedMirRelationExpr
sourcepub fn declare_optimized(expr: MirRelationExpr) -> OptimizedMirRelationExpr
pub fn declare_optimized(expr: MirRelationExpr) -> OptimizedMirRelationExpr
Declare that the input expr
is optimized, without actually running it
through an optimizer. This can be useful to mark as optimized literal
MirRelationExpr
s that are obviously optimal, without invoking the whole
machinery of the optimizer.
sourcepub fn as_inner(&self) -> &MirRelationExpr
pub fn as_inner(&self) -> &MirRelationExpr
Get mutable access to the inner MirRelationExpr
Callers of this method need to ensure that the underlying expression stays optimized after any mutations are applied
sourcepub fn as_inner_mut(&mut self) -> &mut MirRelationExpr
pub fn as_inner_mut(&mut self) -> &mut MirRelationExpr
Get mutable access to the inner MirRelationExpr
Callers of this method need to ensure that the underlying expression stays optimized after any mutations are applied
pub fn into_inner(self) -> MirRelationExpr
Methods from Deref<Target = MirRelationExpr>§
sourcepub fn typ(&self) -> RelationType
pub fn typ(&self) -> RelationType
Reports the schema of the relation.
This method determines the type through recursive traversal of the relation expression, drawing from the types of base collections. As such, this is not an especially cheap method, and should be used judiciously.
The relation type is computed incrementally with a recursive post-order
traversal, that accumulates the input types for the relations yet to be
visited in type_stack
.
sourcepub fn typ_with_input_types(&self, input_types: &[RelationType]) -> RelationType
pub fn typ_with_input_types(&self, input_types: &[RelationType]) -> RelationType
Reports the schema of the relation given the schema of the input relations.
input_types
is required to contain the schemas for the input relations of
the current relation in the same order as they are visited by try_visit_children
method, even though not all may be used for computing the schema of the
current relation. For example, Let
expects two input types, one for the
value relation and one for the body, in that order, but only the one for the
body is used to determine the type of the Let
relation.
It is meant to be used during post-order traversals to compute relation schemas incrementally.
sourcepub fn col_with_input_cols<'a, I>(&self, input_types: I) -> Vec<ColumnType>
pub fn col_with_input_cols<'a, I>(&self, input_types: I) -> Vec<ColumnType>
Reports the column types of the relation given the column types of the input relations.
This method delegates to try_col_with_input_cols
, panicing if an Err
variant is returned.
sourcepub fn try_col_with_input_cols<'a, I>(
&self,
input_types: I,
) -> Result<Vec<ColumnType>, String>
pub fn try_col_with_input_cols<'a, I>( &self, input_types: I, ) -> Result<Vec<ColumnType>, String>
Reports the column types of the relation given the column types of the input relations.
input_types
is required to contain the column types for the input relations of
the current relation in the same order as they are visited by try_visit_children
method, even though not all may be used for computing the schema of the
current relation. For example, Let
expects two input types, one for the
value relation and one for the body, in that order, but only the one for the
body is used to determine the type of the Let
relation.
It is meant to be used during post-order traversals to compute column types incrementally.
sourcepub fn keys_with_input_keys<'a, I, J>(
&self,
input_arities: I,
input_keys: J,
) -> Vec<Vec<usize>>
pub fn keys_with_input_keys<'a, I, J>( &self, input_arities: I, input_keys: J, ) -> Vec<Vec<usize>>
Reports the unique keys of the relation given the arities and the unique keys of the input relations.
input_arities
and input_keys
are required to contain the
corresponding info for the input relations of
the current relation in the same order as they are visited by try_visit_children
method, even though not all may be used for computing the schema of the
current relation. For example, Let
expects two input types, one for the
value relation and one for the body, in that order, but only the one for the
body is used to determine the type of the Let
relation.
It is meant to be used during post-order traversals to compute unique keys incrementally.
sourcepub fn arity(&self) -> usize
pub fn arity(&self) -> usize
The number of columns in the relation.
This number is determined from the type, which is determined recursively at non-trivial cost.
The arity is computed incrementally with a recursive post-order
traversal, that accumulates the arities for the relations yet to be
visited in arity_stack
.
sourcepub fn arity_with_input_arities<I>(&self, input_arities: I) -> usize
pub fn arity_with_input_arities<I>(&self, input_arities: I) -> usize
Reports the arity of the relation given the schema of the input relations.
input_arities
is required to contain the arities for the input relations of
the current relation in the same order as they are visited by try_visit_children
method, even though not all may be used for computing the schema of the
current relation. For example, Let
expects two input types, one for the
value relation and one for the body, in that order, but only the one for the
body is used to determine the type of the Let
relation.
It is meant to be used during post-order traversals to compute arities incrementally.
sourcepub fn num_inputs(&self) -> usize
pub fn num_inputs(&self) -> usize
The number of child relations this relation has.
sourcepub fn as_const(
&self,
) -> Option<(&Result<Vec<(Row, Diff)>, EvalError>, &RelationType)>
pub fn as_const( &self, ) -> Option<(&Result<Vec<(Row, Diff)>, EvalError>, &RelationType)>
If self is a constant, return the value and the type, otherwise None
.
Looks behind ArrangeBy
s.
sourcepub fn as_const_err(&self) -> Option<&EvalError>
pub fn as_const_err(&self) -> Option<&EvalError>
If self is a constant error, return the error, otherwise None
.
Looks behind ArrangeBy
s.
sourcepub fn is_constant_singleton(&self) -> bool
pub fn is_constant_singleton(&self) -> bool
Checks if self
is the single element collection with no columns.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Indicates if this is a constant empty collection.
A false value does not mean the collection is known to be non-empty, only that we cannot currently determine that it is statically empty.
sourcepub fn is_negated_project(&self) -> Option<(&MirRelationExpr, &[usize])>
pub fn is_negated_project(&self) -> Option<(&MirRelationExpr, &[usize])>
If the expression is a negated project, return the input and the projection.
sourcepub fn pretty(&self) -> String
pub fn pretty(&self) -> String
Pretty-print this MirRelationExpr to a string.
sourcepub fn explain(
&self,
config: &ExplainConfig,
humanizer: Option<&dyn ExprHumanizer>,
) -> String
pub fn explain( &self, config: &ExplainConfig, humanizer: Option<&dyn ExprHumanizer>, ) -> String
Pretty-print this MirRelationExpr to a string using a custom ExplainConfig and an optionally provided ExprHumanizer.
sourcepub fn contains_temporal(&self) -> bool
pub fn contains_temporal(&self) -> bool
True iff the expression contains a NullaryFunc::MzLogicalTimestamp
.
sourcepub fn try_visit_scalars_1<F, E>(&self, f: &mut F) -> Result<(), E>
pub fn try_visit_scalars_1<F, E>(&self, f: &mut F) -> Result<(), E>
Fallible visitor for the MirScalarExpr
s directly owned by this relation expression.
The f
visitor should not recursively descend into owned MirRelationExpr
s.
sourcepub fn try_visit_scalars<F, E>(&self, f: &mut F) -> Result<(), E>
pub fn try_visit_scalars<F, E>(&self, f: &mut F) -> Result<(), E>
Fallible immutable visitor for the MirScalarExpr
s in the MirRelationExpr
subtree
rooted at self
.
Note that this does not recurse into MirRelationExpr
subtrees within MirScalarExpr
nodes.
sourcepub fn visit_scalars<F>(&self, f: &mut F)where
F: FnMut(&MirScalarExpr),
pub fn visit_scalars<F>(&self, f: &mut F)where
F: FnMut(&MirScalarExpr),
Infallible immutable visitor for the MirScalarExpr
s in the MirRelationExpr
subtree
rooted at self
.
Note that this does not recurse into MirRelationExpr
subtrees within MirScalarExpr
nodes.
sourcepub fn debug_size_and_depth(&self) -> (usize, usize)
pub fn debug_size_and_depth(&self) -> (usize, usize)
Computes the size (total number of nodes) and maximum depth of a MirRelationExpr for debug printing purposes.
sourcepub fn could_run_expensive_function(&self) -> bool
pub fn could_run_expensive_function(&self) -> bool
The MirRelationExpr is considered potentially expensive if and only if at least one of the following conditions is true:
- It contains at least one FlatMap or a Reduce operator.
- It contains at least one MirScalarExpr with a function call.
!!!WARNING!!!: this method has an HirRelationExpr counterpart. The two should be kept in sync w.r.t. HIR ⇒ MIR lowering!
sourcepub fn hash_to_u64(&self) -> u64
pub fn hash_to_u64(&self) -> u64
Hash to an u64 using Rust’s default Hasher. (Which is a somewhat slower, but better Hasher
than what Hashable::hashed
would give us.)
sourcepub fn is_recursive(self: &MirRelationExpr) -> bool
pub fn is_recursive(self: &MirRelationExpr) -> bool
True when expr
contains a LetRec
AST node.
sourcepub fn children(&self) -> impl DoubleEndedIterator<Item = &Self>
pub fn children(&self) -> impl DoubleEndedIterator<Item = &Self>
Iterates through references to child expressions.
sourcepub fn post_order_vec(&self) -> Vec<&Self>
pub fn post_order_vec(&self) -> Vec<&Self>
Return a vector of references to the subtrees of this expression
in post-visit order (the last element is &self
).
fn fmt_virtual_syntax( &self, f: &mut Formatter<'_>, ctx: &mut PlanRenderingContext<'_, MirRelationExpr>, ) -> Result
fn fmt_raw_syntax( &self, f: &mut Formatter<'_>, ctx: &mut PlanRenderingContext<'_, MirRelationExpr>, ) -> Result
fn fmt_attributes( &self, f: &mut Formatter<'_>, ctx: &PlanRenderingContext<'_, MirRelationExpr>, ) -> Result
fn column_names<'a>( &'a self, ctx: &'a PlanRenderingContext<'_, MirRelationExpr>, ) -> Option<&Vec<String>>
Trait Implementations§
source§impl Arbitrary for OptimizedMirRelationExpr
impl Arbitrary for OptimizedMirRelationExpr
§type Parameters = <MirRelationExpr as Arbitrary>::Parameters
type Parameters = <MirRelationExpr as Arbitrary>::Parameters
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = Map<<MirRelationExpr as Arbitrary>::Strategy, fn(_: MirRelationExpr) -> OptimizedMirRelationExpr>
type Strategy = Map<<MirRelationExpr as Arbitrary>::Strategy, fn(_: MirRelationExpr) -> OptimizedMirRelationExpr>
Strategy
used to generate values of type Self
.source§fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy
source§impl Clone for OptimizedMirRelationExpr
impl Clone for OptimizedMirRelationExpr
source§fn clone(&self) -> OptimizedMirRelationExpr
fn clone(&self) -> OptimizedMirRelationExpr
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for OptimizedMirRelationExpr
impl Debug for OptimizedMirRelationExpr
source§impl Deref for OptimizedMirRelationExpr
impl Deref for OptimizedMirRelationExpr
source§impl<'de> Deserialize<'de> for OptimizedMirRelationExpr
impl<'de> Deserialize<'de> for OptimizedMirRelationExpr
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for OptimizedMirRelationExpr
impl PartialEq for OptimizedMirRelationExpr
source§impl Serialize for OptimizedMirRelationExpr
impl Serialize for OptimizedMirRelationExpr
impl Eq for OptimizedMirRelationExpr
impl StructuralPartialEq for OptimizedMirRelationExpr
Auto Trait Implementations§
impl Freeze for OptimizedMirRelationExpr
impl RefUnwindSafe for OptimizedMirRelationExpr
impl Send for OptimizedMirRelationExpr
impl Sync for OptimizedMirRelationExpr
impl Unpin for OptimizedMirRelationExpr
impl UnwindSafe for OptimizedMirRelationExpr
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ProgressEventTimestamp for T
impl<T> ProgressEventTimestamp for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.