pub struct EliminateAggregateDistinct {}Expand description
Optimizer rule that removes a DISTINCT modifier that cannot change the
result of the aggregate it is attached to.
min, max, bool_and, bit_or and friends have an idempotent merge, so
min(DISTINCT x) and min(x) return the same value. Removing the flag here
keeps crate::single_distinct_to_groupby::SingleDistinctToGroupBy from
rewriting the plan into an inner group by that only exists to deduplicate.
An aggregate states how it treats duplicates through
datafusion_expr::AggregateUDFImpl::distinct_handling.
Aggregate: groupBy=[[g]], aggr=[[min(DISTINCT x)]]becomes
Aggregate: groupBy=[[g]], aggr=[[min(x) AS "min(DISTINCT x)"]]The alias keeps the output schema unchanged so the parent projection still resolves.
Implementations§
Trait Implementations§
Source§impl Debug for EliminateAggregateDistinct
impl Debug for EliminateAggregateDistinct
Source§impl Default for EliminateAggregateDistinct
impl Default for EliminateAggregateDistinct
Source§impl OptimizerRule for EliminateAggregateDistinct
impl OptimizerRule for EliminateAggregateDistinct
Source§fn apply_order(&self) -> Option<ApplyOrder>
fn apply_order(&self) -> Option<ApplyOrder>
How should the rule be applied by the optimizer? See comments on
ApplyOrder for details. Read moreSource§fn rewrite(
&self,
plan: LogicalPlan,
_config: &dyn OptimizerConfig,
) -> Result<Transformed<LogicalPlan>>
fn rewrite( &self, plan: LogicalPlan, _config: &dyn OptimizerConfig, ) -> Result<Transformed<LogicalPlan>>
Try to rewrite
plan to an optimized form, returning Transformed::yes
if the plan was rewritten and Transformed::no if it was not. Read moreAuto Trait Implementations§
impl Forget for EliminateAggregateDistinct
impl Freeze for EliminateAggregateDistinct
impl Move for EliminateAggregateDistinct
impl RefUnwindSafe for EliminateAggregateDistinct
impl Send for EliminateAggregateDistinct
impl Sync for EliminateAggregateDistinct
impl Unpin for EliminateAggregateDistinct
impl UnsafeUnpin for EliminateAggregateDistinct
impl UnwindSafe for EliminateAggregateDistinct
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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