Skip to content

Commit 9b2f63b

Browse files
add distinct arg to count
1 parent e3a4a7a commit 9b2f63b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/functions.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,13 @@ fn col(name: &str) -> PyResult<PyExpr> {
604604
/// Wrapper for [`functions_aggregate::expr_fn::count`]
605605
/// Count the number of non-null values in the column
606606
#[pyfunction]
607-
fn count(expr: PyExpr) -> PyExpr {
608-
functions_aggregate::expr_fn::count(expr.expr).into()
607+
fn count(expr: PyExpr, distinct: bool) -> PyResult<PyExpr> {
608+
let expr = functions_aggregate::expr_fn::count(expr.expr);
609+
if distinct {
610+
Ok(expr.distinct().build()?.into())
611+
} else {
612+
Ok(expr.into())
613+
}
609614
}
610615

611616
/// Create a CASE WHEN statement with literal WHEN expressions for comparison to the base expression.

0 commit comments

Comments
 (0)