pub struct PhysicalGroupBy {
expr: Vec<(Arc<dyn PhysicalExpr>, String)>,
null_expr: Vec<(Arc<dyn PhysicalExpr>, String)>,
groups: Vec<Vec<bool>>,
}Expand description
Represents GROUP BY clause in the plan (including the more general GROUPING SET)
In the case of a simple GROUP BY a, b clause, this will contain the expression [a, b]
and a single group [false, false].
In the case of GROUP BY GROUPING SETS/CUBE/ROLLUP the planner will expand the expression
into multiple groups, using null expressions to align each group.
For example, with a group by clause GROUP BY GROUPING SETS ((a,b),(a),(b)) the planner should
create a PhysicalGroupBy like
PhysicalGroupBy {
expr: [(col(a), a), (col(b), b)],
null_expr: [(NULL, a), (NULL, b)],
groups: [
[false, false], // (a,b)
[false, true], // (a) <=> (a, NULL)
[true, false] // (b) <=> (NULL, b)
]
}Fields§
§expr: Vec<(Arc<dyn PhysicalExpr>, String)>Distinct (Physical Expr, Alias) in the grouping set
null_expr: Vec<(Arc<dyn PhysicalExpr>, String)>Corresponding NULL expressions for expr
groups: Vec<Vec<bool>>Null mask for each group in this grouping set. Each group is
composed of either one of the group expressions in expr or a null
expression in null_expr. If groups[i][j] is true, then the
j-th expression in the i-th group is NULL, otherwise it is expr[j].
Implementations§
Source§impl PhysicalGroupBy
impl PhysicalGroupBy
Sourcepub fn new(
expr: Vec<(Arc<dyn PhysicalExpr>, String)>,
null_expr: Vec<(Arc<dyn PhysicalExpr>, String)>,
groups: Vec<Vec<bool>>,
) -> Self
pub fn new( expr: Vec<(Arc<dyn PhysicalExpr>, String)>, null_expr: Vec<(Arc<dyn PhysicalExpr>, String)>, groups: Vec<Vec<bool>>, ) -> Self
Create a new PhysicalGroupBy
Sourcepub fn new_single(expr: Vec<(Arc<dyn PhysicalExpr>, String)>) -> Self
pub fn new_single(expr: Vec<(Arc<dyn PhysicalExpr>, String)>) -> Self
Create a GROUPING SET with only a single group. This is the “standard”
case when building a plan from an expression such as GROUP BY a,b,c
Sourcepub fn exprs_nullable(&self) -> Vec<bool>
pub fn exprs_nullable(&self) -> Vec<bool>
Calculate GROUP BY expressions nullable
Sourcepub fn expr(&self) -> &[(Arc<dyn PhysicalExpr>, String)]
pub fn expr(&self) -> &[(Arc<dyn PhysicalExpr>, String)]
Returns the group expressions
Sourcepub fn null_expr(&self) -> &[(Arc<dyn PhysicalExpr>, String)]
pub fn null_expr(&self) -> &[(Arc<dyn PhysicalExpr>, String)]
Returns the null expressions
Sourcepub fn input_exprs(&self) -> Vec<Arc<dyn PhysicalExpr>>
pub fn input_exprs(&self) -> Vec<Arc<dyn PhysicalExpr>>
Calculate GROUP BY expressions according to input schema.
Sourcefn num_output_exprs(&self) -> usize
fn num_output_exprs(&self) -> usize
The number of expressions in the output schema.
Sourcepub fn output_exprs(&self) -> Vec<Arc<dyn PhysicalExpr>>
pub fn output_exprs(&self) -> Vec<Arc<dyn PhysicalExpr>>
Return grouping expressions as they occur in the output schema.
Sourcepub fn num_group_exprs(&self) -> usize
pub fn num_group_exprs(&self) -> usize
Returns the number expression as grouping keys.
pub fn group_schema(&self, schema: &Schema) -> Result<SchemaRef>
Sourcefn group_fields(&self, input_schema: &Schema) -> Result<Vec<FieldRef>>
fn group_fields(&self, input_schema: &Schema) -> Result<Vec<FieldRef>>
Returns the fields that are used as the grouping keys.
Sourcefn output_fields(&self, input_schema: &Schema) -> Result<Vec<FieldRef>>
fn output_fields(&self, input_schema: &Schema) -> Result<Vec<FieldRef>>
Returns the output fields of the group by.
This might be different from the group_fields that might contain internal expressions that
should not be part of the output schema.
Sourcepub fn as_final(&self) -> PhysicalGroupBy
pub fn as_final(&self) -> PhysicalGroupBy
Returns the PhysicalGroupBy for a final aggregation if self is used for a partial
aggregation.
Trait Implementations§
Source§impl Clone for PhysicalGroupBy
impl Clone for PhysicalGroupBy
Source§fn clone(&self) -> PhysicalGroupBy
fn clone(&self) -> PhysicalGroupBy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PhysicalGroupBy
impl Debug for PhysicalGroupBy
Source§impl Default for PhysicalGroupBy
impl Default for PhysicalGroupBy
Source§fn default() -> PhysicalGroupBy
fn default() -> PhysicalGroupBy
Source§impl PartialEq for PhysicalGroupBy
impl PartialEq for PhysicalGroupBy
Auto Trait Implementations§
impl Freeze for PhysicalGroupBy
impl !RefUnwindSafe for PhysicalGroupBy
impl Send for PhysicalGroupBy
impl Sync for PhysicalGroupBy
impl Unpin for PhysicalGroupBy
impl !UnwindSafe for PhysicalGroupBy
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more