Skip to content

Commit

Permalink
add expr_fn::median (#5437)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzhx authored Mar 1, 2023
1 parent d076ab3 commit eef0464
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions datafusion/expr/src/expr_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ pub fn approx_distinct(expr: Expr) -> Expr {
))
}

/// Calculate the median for `expr`.
pub fn median(expr: Expr) -> Expr {
Expr::AggregateFunction(AggregateFunction::new(
aggregate_function::AggregateFunction::Median,
vec![expr],
false,
None,
))
}

/// Calculate an approximation of the median for `expr`.
pub fn approx_median(expr: Expr) -> Expr {
Expr::AggregateFunction(AggregateFunction::new(
Expand Down

0 comments on commit eef0464

Please sign in to comment.