Skip to content

Commit 7a23ea9

Browse files
authored
Minor: return "not supported" for COUNT DISTINCT with multiple arguments (#11391)
* Minor: return "not supported" for COUNT DISTINCT with multiple arguments * update condition
1 parent d3f6372 commit 7a23ea9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

datafusion/functions-aggregate/src/count.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use arrow::{
3737
buffer::BooleanBuffer,
3838
};
3939
use datafusion_common::{
40-
downcast_value, internal_err, DataFusionError, Result, ScalarValue,
40+
downcast_value, internal_err, not_impl_err, DataFusionError, Result, ScalarValue,
4141
};
4242
use datafusion_expr::function::StateFieldsArgs;
4343
use datafusion_expr::{
@@ -138,6 +138,10 @@ impl AggregateUDFImpl for Count {
138138
return Ok(Box::new(CountAccumulator::new()));
139139
}
140140

141+
if acc_args.input_exprs.len() > 1 {
142+
return not_impl_err!("COUNT DISTINCT with multiple arguments");
143+
}
144+
141145
let data_type = acc_args.input_type;
142146
Ok(match data_type {
143147
// try and use a specialized accumulator if possible, otherwise fall back to generic accumulator

datafusion/sqllogictest/test_files/aggregate.slt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,10 @@ SELECT count(c1, c2) FROM test
20192019
----
20202020
3
20212021

2022+
# count(distinct) with multiple arguments
2023+
query error DataFusion error: This feature is not implemented: COUNT DISTINCT with multiple arguments
2024+
SELECT count(distinct c1, c2) FROM test
2025+
20222026
# count_null
20232027
query III
20242028
SELECT count(null), count(null, null), count(distinct null) FROM test

0 commit comments

Comments
 (0)