Skip to content

Commit

Permalink
Support for median(distinct) aggregation function (#10226)
Browse files Browse the repository at this point in the history
* Support for median(distinct) aggregation function

* Reduce duplication
  • Loading branch information
Jefffrey authored Apr 26, 2024
1 parent ff5eb8f commit c22c299
Show file tree
Hide file tree
Showing 6 changed files with 437 additions and 43 deletions.
10 changes: 10 additions & 0 deletions datafusion/core/benches/aggregate_query_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ fn criterion_benchmark(c: &mut Criterion) {
)
})
});

c.bench_function("aggregate_query_distinct_median", |b| {
b.iter(|| {
query(
ctx.clone(),
"SELECT MEDIAN(DISTINCT u64_wide), MEDIAN(DISTINCT u64_narrow) \
FROM t",
)
})
});
}

criterion_group!(benches, criterion_benchmark);
Expand Down
6 changes: 2 additions & 4 deletions datafusion/physical-expr/src/aggregate/build_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,12 @@ pub fn create_aggregate_expr(
"APPROX_MEDIAN(DISTINCT) aggregations are not available"
);
}
(AggregateFunction::Median, false) => Arc::new(expressions::Median::new(
(AggregateFunction::Median, distinct) => Arc::new(expressions::Median::new(
input_phy_exprs[0].clone(),
name,
data_type,
distinct,
)),
(AggregateFunction::Median, true) => {
return not_impl_err!("MEDIAN(DISTINCT) aggregations are not available");
}
(AggregateFunction::FirstValue, _) => Arc::new(
expressions::FirstValue::new(
input_phy_exprs[0].clone(),
Expand Down
Loading

0 comments on commit c22c299

Please sign in to comment.