Skip to content

Commit

Permalink
Minor: return "not supported" for COUNT DISTINCT with multiple argu…
Browse files Browse the repository at this point in the history
…ments (apache#11391)

* Minor: return "not supported" for COUNT DISTINCT with multiple arguments

* update condition
  • Loading branch information
jonahgao authored Jul 11, 2024
1 parent d3f6372 commit 7a23ea9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion datafusion/functions-aggregate/src/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use arrow::{
buffer::BooleanBuffer,
};
use datafusion_common::{
downcast_value, internal_err, DataFusionError, Result, ScalarValue,
downcast_value, internal_err, not_impl_err, DataFusionError, Result, ScalarValue,
};
use datafusion_expr::function::StateFieldsArgs;
use datafusion_expr::{
Expand Down Expand Up @@ -138,6 +138,10 @@ impl AggregateUDFImpl for Count {
return Ok(Box::new(CountAccumulator::new()));
}

if acc_args.input_exprs.len() > 1 {
return not_impl_err!("COUNT DISTINCT with multiple arguments");
}

let data_type = acc_args.input_type;
Ok(match data_type {
// try and use a specialized accumulator if possible, otherwise fall back to generic accumulator
Expand Down
4 changes: 4 additions & 0 deletions datafusion/sqllogictest/test_files/aggregate.slt
Original file line number Diff line number Diff line change
Expand Up @@ -2019,6 +2019,10 @@ SELECT count(c1, c2) FROM test
----
3

# count(distinct) with multiple arguments
query error DataFusion error: This feature is not implemented: COUNT DISTINCT with multiple arguments
SELECT count(distinct c1, c2) FROM test

# count_null
query III
SELECT count(null), count(null, null), count(distinct null) FROM test
Expand Down

0 comments on commit 7a23ea9

Please sign in to comment.