Skip to content

Commit a6a477f

Browse files
committed
test: add count distinct dictionary nulls
1 parent 78ad8a5 commit a6a477f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

datafusion/functions-aggregate/src/count.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ impl Accumulator for DistinctCountAccumulator {
711711
}
712712

713713
(0..arr.len()).try_for_each(|index| {
714-
if !arr.is_null(index) {
715-
let scalar = ScalarValue::try_from_array(arr, index)?;
714+
let scalar = ScalarValue::try_from_array(arr, index)?;
715+
if !scalar.is_null() {
716716
self.values.insert(scalar);
717717
}
718718
Ok(())

datafusion/sqllogictest/test_files/aggregate.slt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5043,6 +5043,20 @@ select count(distinct column1), count(distinct column2) from dict_test group by
50435043
statement ok
50445044
drop table dict_test;
50455045

5046+
## count distinct dictionary with null values
5047+
statement ok
5048+
create table dict_null_test as
5049+
select arrow_cast(NULL, 'Dictionary(Int32, Utf8)') as d
5050+
from (values (1), (2), (3), (4), (5));
5051+
5052+
query I
5053+
select count(distinct d) from dict_null_test;
5054+
----
5055+
0
5056+
5057+
statement ok
5058+
drop table dict_null_test;
5059+
50465060
# avg_duration
50475061

50485062
statement ok

0 commit comments

Comments
 (0)