This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new cd47b95508 feat: Support FixedSizedBinary type for approx_distinct
(#23417)
cd47b95508 is described below
commit cd47b9550859368708898b1b0cd0e473c9a3a289
Author: Michael Kleen <[email protected]>
AuthorDate: Thu Jul 9 14:59:59 2026 +0200
feat: Support FixedSizedBinary type for approx_distinct (#23417)
## Which issue does this PR close?
- Relates to https://github.com/apache/datafusion/issues/22989 but does
not close it. More types are coming.
## Rationale for this change
- Support the `FixedSizedBinary` type for `approx_distinct`
- The Arrow type `FixedSizedBinary` can be directly supported for
`HLLAccumulator` and `HllGroupsAccumulator`
## What changes are included in this PR?
- Enable `HLLAccumulator` and `HllGroupsAccumulator` to support
`FixedSizedBinary`
- Tests for the non-grouped and grouped path as part of `aggregate.slt`
## Are these changes tested?
Yes
## Are there any user-facing changes?
Yes, `approx_distinct` supports now `FixedSizedBinary` but no breaking
changes.
---
datafusion/functions-aggregate/src/approx_distinct.rs | 2 ++
datafusion/sqllogictest/test_files/aggregate.slt | 16 ++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/datafusion/functions-aggregate/src/approx_distinct.rs
b/datafusion/functions-aggregate/src/approx_distinct.rs
index a8dbd8611d..0e35b47d64 100644
--- a/datafusion/functions-aggregate/src/approx_distinct.rs
+++ b/datafusion/functions-aggregate/src/approx_distinct.rs
@@ -799,6 +799,7 @@ impl AggregateUDFImpl for ApproxDistinct {
| DataType::Utf8View
| DataType::Binary
| DataType::BinaryView
+ | DataType::FixedSizeBinary(_)
| DataType::LargeBinary => Box::new(HLLAccumulator::new()),
DataType::Null => {
Box::new(NoopAccumulator::new(ScalarValue::UInt64(Some(0))))
@@ -868,6 +869,7 @@ fn is_hll_groups_type(data_type: &DataType) -> bool {
| DataType::Utf8View
| DataType::Binary
| DataType::BinaryView
+ | DataType::FixedSizeBinary(_)
| DataType::LargeBinary
)
}
diff --git a/datafusion/sqllogictest/test_files/aggregate.slt
b/datafusion/sqllogictest/test_files/aggregate.slt
index 37ee3d8a95..c5970bde9c 100644
--- a/datafusion/sqllogictest/test_files/aggregate.slt
+++ b/datafusion/sqllogictest/test_files/aggregate.slt
@@ -1953,6 +1953,22 @@ SELECT g, approx_distinct(arrow_cast(arrow_cast(s,
'Binary'), 'BinaryView')) FRO
4 1
+# FixedSizeBinary non-grouped
+query I
+SELECT approx_distinct(arrow_cast(arrow_cast(s, 'Binary'),
'FixedSizeBinary(1)')) FROM approx_distinct_group_test WHERE g = 2;
+----
+2
+
+# FixedSizeBinary grouped
+query II
+SELECT g, approx_distinct(arrow_cast(arrow_cast(s, 'Binary'),
'FixedSizeBinary(1)')) FROM approx_distinct_group_test GROUP BY g ORDER BY g;
+----
+1 2
+2 2
+3 0
+4 1
+
+
# Integers (Int32): group 1 -> {10,20}=2, group 2 -> {30,40}=2, group 3 -> 0,
group 4 -> {50}=1
query II
SELECT g, approx_distinct(i) FROM approx_distinct_group_test GROUP BY g ORDER
BY g;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]