Expand description
Transformations for relation expressions.
This crate contains traits, types, and methods suitable for transforming
MirRelationExpr
types in ways that preserve semantics and improve performance.
The core trait is Transform
, and many implementors of this trait can be
boxed and iterated over. Some common transformation patterns are wrapped
as Transform
implementors themselves.
The crate also contains the beginnings of whole-dataflow optimization, which uses the same analyses but spanning multiple dataflow elements.
Re-exports§
pub use dataflow::optimize_dataflow;
Modules§
- analysis
- Traits and types for reusable expression analysis
- canonicalization
- Transformations that bring relation expressions to their canonical form.
- canonicalize_
mfp - Canonicalizes MFPs, e.g., performs CSE on the scalar expressions, eliminates identity MFPs.
- column_
knowledge - Transformations based on pulling information about individual columns from sources.
- compound
- Transformations that don’t fit into one of the
canonicalization
,fusion
,movement
, orordering
buckets. - cse
- Common subexpression elimination.
- dataflow
- Whole-dataflow optimization
- demand
- Transformation based on pushing demand information about columns toward sources.
- equivalence_
propagation - Propagates expression equivalence from leaves to root, and back down again.
- fold_
constants - Replace operators on constants collections with constant collections.
- fusion
- Transformations that fuse together others of their kind.
- join_
implementation - Determines the join implementation for join operators.
- literal_
constraints - See if there are predicates of the form
<expr> = literal
that can be sped up using an index. More specifically, look for an MFP on top of a Get, where the MFP has an appropriate filter, and the Get has a matching index. Convert these toIndexedFilter
joins, which is a semi-join with a constant collection. - literal_
lifting - Hoist literal values from maps wherever possible.
- monotonic
- Analysis to identify monotonic collections, especially TopK inputs.
- movement
- Transformations that move relation expressions up (lifting) and down (pushdown) the tree.
- non_
null_ requirements - Push non-null requirements toward sources.
- normalize_
lets - Normalize the structure of
Let
andLetRec
operators in expressions. - normalize_
ops - Normalize the structure of various operators.
- notice
- Notices that the optimizer wants to show to users.
- ordering
- Transformations that impose a canonical order on the inputs of multi-input relation expressions.
- predicate_
pushdown - Pushes predicates down through other operators.
- reduce_
elision - Removes
Reduce
when the input has as unique keys the keys of the reduce. - reduce_
reduction - Breaks complex
Reduce
variants into a join of simpler variants. - reduction_
pushdown - Tries to convert a reduce around a join to a join of reduces. Also absorbs Map operators into Reduce operators.
- redundant_
join - Remove redundant collections of distinct elements from joins.
- semijoin_
idempotence - Remove semijoins that are applied multiple times to no further effect.
- threshold_
elision - Remove Threshold operators when we are certain no records have negative multiplicity.
- typecheck
- Check that the visible type of each query has not been changed
- union_
cancel - Detects an input being unioned with its negation and cancels them out
- will_
distinct - Transform that pushes down the information that a collection will be subjected to a
Distinct
on specific columns.
Macros§
- all
- Compute the conjunction of a variadic number of expressions.
- any
- Compute the disjunction of a variadic number of expressions.
- transforms 🔒
- Convenience macro for guarding transforms behind a feature flag.
Structs§
- Empty
Index Oracle - An
IndexOracle
that knows about no indexes. - Empty
Statistics Oracle - A
StatisticsOracle
that knows nothing and can give no estimates. - Fixpoint
- A sequence of transformations iterated some number of times.
- Fuse
AndCollapse - A sequence of transformations that simplify the
MirRelationExpr
- Optimizer
- A naive optimizer for relation expressions.
- Transform
Ctx - Arguments that get threaded through all transforms, plus a
DataflowMetainfo
that can be manipulated by the transforms.
Enums§
- Transform
Error - Errors that can occur during a transformation.
Constants§
Traits§
- Index
Oracle - A trait for a type that can answer questions about what indexes exist.
- Maybe
Should Panic - Implemented by error types that sometimes want to indicate that an error should cause a panic
even in a
catch_unwind
context. Useful for implementingmz_unsafe.mz_panic('forced panic')
. - Statistics
Oracle - A trait for a type that can estimate statistics about a given
GlobalId
- Transform
- Types capable of transforming relation expressions.
Functions§
- catch_
unwind_ optimize - Catch panics in the given optimization, and demote them to
TransformError::Internal
error. - fold_
constants_ fixpoint - Does constant folding to a fixpoint: An expression all of whose leaves are constants, of size
small enough to be inlined and folded should reach a single
MirRelationExpr::Constant
. - fuse_
and_ collapse_ fixpoint - Run the
FuseAndCollapse
transforms in a fixpoint. - normalize
- Construct a normalizing transform that runs transforms that normalize the structure of the tree until a fixpoint.