Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EliminateAggDistinct optimizer rule, implement distinct aggs in Python #1006

Merged
merged 7 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dask_planner/src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,25 @@ impl PyExpr {
}
}

#[pyo3(name = "isDistinctAgg")]
pub fn is_distinct_aggregation(&self) -> PyResult<bool> {
// TODO refactor to avoid duplication
match &self.expr {
Expr::AggregateFunction { distinct, .. } => Ok(*distinct),
Expr::AggregateUDF { .. } => Ok(false),
Expr::Alias(expr, _) => match expr.as_ref() {
Expr::AggregateFunction { distinct, .. } => Ok(*distinct),
Expr::AggregateUDF { .. } => Ok(false),
_ => Err(py_type_err(
"isDistinctAgg() - Non-aggregate expression encountered",
)),
},
_ => Err(py_type_err(
"getFilterExpr() - Non-aggregate expression encountered",
)),
}
}

/// Returns if a sort expressions is an ascending sort
#[pyo3(name = "isSortAscending")]
pub fn is_sort_ascending(&self) -> PyResult<bool> {
Expand Down
4 changes: 0 additions & 4 deletions dask_planner/src/sql/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ use datafusion_optimizer::{
};
use log::trace;

mod eliminate_agg_distinct;
use eliminate_agg_distinct::EliminateAggDistinct;

/// Houses the optimization logic for Dask-SQL. This optimization controls the optimizations
/// and their ordering in regards to their impact on the underlying `LogicalPlan` instance
pub struct DaskSqlOptimizer {
Expand Down Expand Up @@ -65,7 +62,6 @@ impl DaskSqlOptimizer {
Arc::new(PushDownFilter::new()),
Arc::new(LimitPushDown::new()),
// Dask-SQL specific optimizations
Arc::new(EliminateAggDistinct::new()),
// The previous optimizations added expressions and projections,
// that might benefit from the following rules
Arc::new(SimplifyExpressions::new()),
Expand Down
Loading