Enum sql::plan::HirRelationExpr [−][src]
pub enum HirRelationExpr {
Show 15 variants
Constant {
rows: Vec<Row>,
typ: RelationType,
},
Get {
id: Id,
typ: RelationType,
},
Let {
name: String,
id: LocalId,
value: Box<HirRelationExpr>,
body: Box<HirRelationExpr>,
},
Project {
input: Box<HirRelationExpr>,
outputs: Vec<usize>,
},
Map {
input: Box<HirRelationExpr>,
scalars: Vec<HirScalarExpr>,
},
CallTable {
func: TableFunc,
exprs: Vec<HirScalarExpr>,
},
Filter {
input: Box<HirRelationExpr>,
predicates: Vec<HirScalarExpr>,
},
Join {
left: Box<HirRelationExpr>,
right: Box<HirRelationExpr>,
on: HirScalarExpr,
kind: JoinKind,
},
Reduce {
input: Box<HirRelationExpr>,
group_key: Vec<usize>,
aggregates: Vec<AggregateExpr>,
expected_group_size: Option<usize>,
},
Distinct {
input: Box<HirRelationExpr>,
},
TopK {
input: Box<HirRelationExpr>,
group_key: Vec<usize>,
order_key: Vec<ColumnOrder>,
limit: Option<usize>,
offset: usize,
},
Negate {
input: Box<HirRelationExpr>,
},
Threshold {
input: Box<HirRelationExpr>,
},
Union {
base: Box<HirRelationExpr>,
inputs: Vec<HirRelationExpr>,
},
DeclareKeys {
input: Box<HirRelationExpr>,
keys: Vec<Vec<usize>>,
},
}
Expand description
Just like MirRelationExpr, except where otherwise noted below.
Variants
Constant
Get
Let
Fields
name: String
id: LocalId
The identifier to be used in Get
variants to retrieve value
.
value: Box<HirRelationExpr>
The collection to be bound to name
.
body: Box<HirRelationExpr>
The result of the Let
, evaluated with name
bound to value
.
CTE
Project
Map
CallTable
Filter
Join
Unlike MirRelationExpr, we haven’t yet compiled LeftOuter/RightOuter/FullOuter joins away into more primitive exprs
Reduce
Unlike MirRelationExpr, when key
is empty AND input
is empty this returns
a single row with the aggregates evaluated over empty groups, rather than returning zero
rows
Distinct
Fields
input: Box<HirRelationExpr>
TopK
Fields
input: Box<HirRelationExpr>
The source collection.
order_key: Vec<ColumnOrder>
Column indices used to order rows within groups.
offset: usize
Number of records to skip
Groups and orders within each group, limiting output.
Negate
Fields
input: Box<HirRelationExpr>
Threshold
Fields
input: Box<HirRelationExpr>
Union
DeclareKeys
Implementations
pub fn typ(
&self,
outers: &[RelationType],
params: &BTreeMap<usize, ScalarType>
) -> RelationType
Reports whether this expression contains a column reference to its direct parent scope.
pub fn reduce(
self,
group_key: Vec<usize>,
aggregates: Vec<AggregateExpr>,
expected_group_size: Option<usize>
) -> Self
pub fn top_k(
self,
group_key: Vec<usize>,
order_key: Vec<ColumnOrder>,
limit: Option<usize>,
offset: usize
) -> Self
pub fn join(
self,
right: HirRelationExpr,
on: HirScalarExpr,
kind: JoinKind
) -> HirRelationExpr
pub fn visit_fallible<'a, F, E>(
&'a self,
depth: usize,
f: &mut F
) -> Result<(), E> where
F: FnMut(&'a Self, usize) -> Result<(), E>,
pub fn visit1<'a, F, E>(&'a self, depth: usize, f: F) -> Result<(), E> where
F: FnMut(&'a Self, usize) -> Result<(), E>,
pub fn visit_mut_fallible<F, E>(
&mut self,
depth: usize,
f: &mut F
) -> Result<(), E> where
F: FnMut(&mut Self, usize) -> Result<(), E>,
pub fn visit1_mut<'a, F, E>(&'a mut self, depth: usize, f: F) -> Result<(), E> where
F: FnMut(&'a mut Self, usize) -> Result<(), E>,
Visits all scalar expressions within the sub-tree of the given relation.
The depth
argument should indicate the subquery nesting depth of the expression,
which will be incremented when entering the RHS of a join or a subquery and
presented to the supplied function f
.
Like visit_scalar_expressions
, but permits mutating the expressions.
Visits the column references in this relation expression.
The depth
argument should indicate the subquery nesting depth of the expression,
which will be incremented when entering the RHS of a join or a subquery and
presented to the supplied function f
.
Like visit_columns
, but permits mutating the column references.
Replaces any parameter references in the expression with the
corresponding datum from params
.
See the documentation for HirScalarExpr::splice_parameters
.
Constructs a constant collection from specific rows and schema.
Rewrite self
into a expr::MirRelationExpr
.
This requires rewriting all correlated subqueries (nested HirRelationExpr
s) into flat queries
fn applied_to(
self,
id_gen: &mut IdGen,
get_outer: MirRelationExpr,
col_map: &ColumnMap,
cte_map: &mut HashMap<LocalId, CteDesc>
) -> MirRelationExpr
fn applied_to(
self,
id_gen: &mut IdGen,
get_outer: MirRelationExpr,
col_map: &ColumnMap,
cte_map: &mut HashMap<LocalId, CteDesc>
) -> MirRelationExpr
Return a expr::MirRelationExpr
which evaluates self
once for each row of get_outer
.
For uncorrelated self
, this should be the cross-product between get_outer
and self
.
When self
references columns of get_outer
, much more work needs to occur.
The col_map
argument contains mappings to some of the columns of get_outer
, though
perhaps not all of them. It should be used as the basis of resolving column references,
but care must be taken when adding new columns that get_outer.arity()
is where they
will start, rather than any function of col_map
.
The get_outer
expression should be a Get
with no duplicate rows, describing the distinct
assignment of values to outer rows.
Perform optimizing algebraic rewrites on this HirRelationExpr
and lower it to a expr::MirRelationExpr
.
The optimization path is fully-determined by the values of the feature flag defined in the OptimizerConfig
.
Trait Implementations
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for HirRelationExpr
impl Send for HirRelationExpr
impl Sync for HirRelationExpr
impl Unpin for HirRelationExpr
impl UnwindSafe for HirRelationExpr
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more