Struct mz_transform::map_lifting::LiteralLifting
source · [−]pub struct LiteralLifting { /* private fields */ }
Expand description
Hoist literal values from maps wherever possible.
Implementations
sourceimpl LiteralLifting
impl LiteralLifting
sourcepub fn action(
&self,
relation: &mut MirRelationExpr,
gets: &mut HashMap<Id, Vec<MirScalarExpr>>
) -> Result<Vec<MirScalarExpr>, TransformError>
pub fn action(
&self,
relation: &mut MirRelationExpr,
gets: &mut HashMap<Id, Vec<MirScalarExpr>>
) -> Result<Vec<MirScalarExpr>, TransformError>
Hoist literal values from maps wherever possible.
Returns a list of literal scalar expressions that must be appended
to the result before it can be correctly used. The intent is that
this action extracts a maximal set of literals from relation
,
which can then often be propagated further up and inlined in any
expressions as it goes.
In several cases, we only manage to extract literals from the final columns. But in those cases where it is possible, permutations are used to move all of the literals to the final columns, and then rely on projection hoisting to allow the these literals to move up the AST.
TODO: The literals from the final columns are returned as the result of this method, whereas literals in intermediate columns are extracted using permutations. The reason for this different treatment is that in some cases it is not possible to remove the projection of the permutation, preventing the lifting of a literal that could otherwise be lifted, the following example being of them:
%0 = | Constant (1, 2, 3) (2, 2, 3)
%1 = | Constant (4, 3, 3) (4, 5, 3)
%2 = | Union %0 %1
If final literals weren’t treated differently, the example above would lead to the following transformed plan:
%0 = | Constant (1) (2) | Map 2, 3 | Project (#0..#2)
%1 = | Constant (3) (5) | Map 4, 3 | Project (#1, #0, #2)
%2 = | Union %0 %1
Since the union branches have different projections, they cannot be removed, preventing literal 3 from being lifted further.
In theory, all literals could be treated in the same way if this method returned both a list of literals and a projection vector, making the caller have to deal with the reshuffling. (see https://github.com/MaterializeInc/materialize/issues/6598)
Trait Implementations
sourceimpl CheckedRecursion for LiteralLifting
impl CheckedRecursion for LiteralLifting
sourcefn recursion_guard(&self) -> &RecursionGuard
fn recursion_guard(&self) -> &RecursionGuard
sourcefn checked_recur<F, T, E>(&self, f: F) -> Result<T, E>where
F: FnOnce(&Self) -> Result<T, E>,
E: From<RecursionLimitError>,
fn checked_recur<F, T, E>(&self, f: F) -> Result<T, E>where
F: FnOnce(&Self) -> Result<T, E>,
E: From<RecursionLimitError>,
f
if so. Read moresourcefn checked_recur_mut<F, T, E>(&mut self, f: F) -> Result<T, E>where
F: FnOnce(&mut Self) -> Result<T, E>,
E: From<RecursionLimitError>,
fn checked_recur_mut<F, T, E>(&mut self, f: F) -> Result<T, E>where
F: FnOnce(&mut Self) -> Result<T, E>,
E: From<RecursionLimitError>,
sourceimpl Debug for LiteralLifting
impl Debug for LiteralLifting
sourceimpl Default for LiteralLifting
impl Default for LiteralLifting
sourcefn default() -> LiteralLifting
fn default() -> LiteralLifting
sourceimpl Transform for LiteralLifting
impl Transform for LiteralLifting
sourcefn transform(
&self,
relation: &mut MirRelationExpr,
_: TransformArgs<'_>
) -> Result<(), TransformError>
fn transform(
&self,
relation: &mut MirRelationExpr,
_: TransformArgs<'_>
) -> Result<(), TransformError>
Auto Trait Implementations
impl !RefUnwindSafe for LiteralLifting
impl Send for LiteralLifting
impl !Sync for LiteralLifting
impl Unpin for LiteralLifting
impl UnwindSafe for LiteralLifting
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> FutureExt for T
impl<T> FutureExt for T
sourcefn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
sourcefn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
sourceimpl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
sourcefn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.sourcefn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.