Struct mz_sql::query_model::mir::Lowerer
source · struct Lowerer<'a> {
model: &'a Model,
id_gen: IdGen,
lets: Vec<(LocalId, MirRelationExpr)>,
common_boxes: HashMap<BoxId, usize>,
}
Fields§
§model: &'a Model
§id_gen: IdGen
Generates mz_expr::LocalId
as an alias for common expressions.
lets: Vec<(LocalId, MirRelationExpr)>
Stack of common expressions that have been given a mz_expr::LocalId
.
common_boxes: HashMap<BoxId, usize>
Map of (BoxIds whose MIR representation has been given a
mz_expr::LocalId
) -> (position of its MIR representation in lets
)
Implementations§
source§impl<'a> Lowerer<'a>
impl<'a> Lowerer<'a>
fn new(model: &'a Model) -> Self
sourcefn push_let(&mut self, rel: MirRelationExpr) -> (MirRelationExpr, Option<usize>)
fn push_let(&mut self, rel: MirRelationExpr) -> (MirRelationExpr, Option<usize>)
Pushes a rel
ation to the stack of common expressions.
If rel
is a mz_expr::MirRelationExpr::Get
, it does not get added to
the stack.
Returns
- the
mz_expr::MirRelationExpr
that will retrieve the common expression. - the location of
rel
, if any, withinself.lets
.
sourcefn lower(&mut self) -> Result<MirRelationExpr, QGMError>
fn lower(&mut self) -> Result<MirRelationExpr, QGMError>
Converts self.model
to a mz_expr::MirRelationExpr
.
sourcefn apply(
&mut self,
box_id: BoxId,
get_outer: MirRelationExpr,
outer_column_map: &HashMap<ColumnReference, usize>
) -> Result<MirRelationExpr, QGMError>
fn apply(
&mut self,
box_id: BoxId,
get_outer: MirRelationExpr,
outer_column_map: &HashMap<ColumnReference, usize>
) -> Result<MirRelationExpr, QGMError>
Applies the given box identified by its ID to the given outer relation.
sourcefn lower_join(
&mut self,
get_outer: MirRelationExpr,
outer_column_map: &HashMap<ColumnReference, usize>,
quantifiers: &BTreeSet<QuantifierId>
) -> Result<(MirRelationExpr, HashMap<ColumnReference, usize>), QGMError>
fn lower_join(
&mut self,
get_outer: MirRelationExpr,
outer_column_map: &HashMap<ColumnReference, usize>,
quantifiers: &BTreeSet<QuantifierId>
) -> Result<(MirRelationExpr, HashMap<ColumnReference, usize>), QGMError>
Generates a join among the result of applying the outer relation to the given quantifiers. Returns a relation and a map of column references that can be used to lower expressions that sit directly on top of the join.
The quantifiers are joined on the columns of the outer relation. TODO(asenac) Since decorrelation is not yet supported the outer relation is currently always the join identity, so the result of this method is always a cross-join of the given quantifiers, which makes part of this code untesteable at the moment.
sourcefn lower_join_inner(
&mut self,
outer_column_map: &HashMap<ColumnReference, usize>,
outer_arity: usize,
inputs: Vec<(QuantifierId, MirRelationExpr)>
) -> (MirRelationExpr, HashMap<ColumnReference, usize>)
fn lower_join_inner(
&mut self,
outer_column_map: &HashMap<ColumnReference, usize>,
outer_arity: usize,
inputs: Vec<(QuantifierId, MirRelationExpr)>
) -> (MirRelationExpr, HashMap<ColumnReference, usize>)
Same as lower_join
except the outer relation has already been applied
to the quantifiers.
sourcefn lower_quantifier(
&mut self,
quantifier_id: QuantifierId,
get_outer: MirRelationExpr,
outer_column_map: &HashMap<ColumnReference, usize>
) -> Result<MirRelationExpr, QGMError>
fn lower_quantifier(
&mut self,
quantifier_id: QuantifierId,
get_outer: MirRelationExpr,
outer_column_map: &HashMap<ColumnReference, usize>
) -> Result<MirRelationExpr, QGMError>
Lowers the given quantifier by applying it to the outer relation.
fn lower_box_columns(
rel: MirRelationExpr,
the_box: &BoundRef<'_, QueryBox>,
column_map: &HashMap<ColumnReference, usize>,
outer_arity: usize,
input_arity: usize
) -> Result<MirRelationExpr, QGMError>
sourcefn join_on_prefix(
join_inputs: Vec<MirRelationExpr>,
prefix_length: usize
) -> (MirRelationExpr, JoinInputMapper)
fn join_on_prefix(
join_inputs: Vec<MirRelationExpr>,
prefix_length: usize
) -> (MirRelationExpr, JoinInputMapper)
Join the given inputs on a shared common prefix.
TODO(asenac) Given the lack of support for decorrelation at the moment, this
method is always called with prefix_length
0, and hence, it remains untested.
sourcefn lower_expression(
expr: &BoxScalarExpr,
column_map: &HashMap<ColumnReference, usize>
) -> Result<MirScalarExpr, QGMError>
fn lower_expression(
expr: &BoxScalarExpr,
column_map: &HashMap<ColumnReference, usize>
) -> Result<MirScalarExpr, QGMError>
Lowers a scalar expression, resolving the column references using the supplied column map.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Lowerer<'a>
impl<'a> !Send for Lowerer<'a>
impl<'a> !Sync for Lowerer<'a>
impl<'a> Unpin for Lowerer<'a>
impl<'a> !UnwindSafe for Lowerer<'a>
Blanket Implementations§
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> Pointable for T
impl<T> Pointable 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
.