2010YOUY01 commented on code in PR #25659:
URL: https://github.com/apache/datafusion/pull/25659#discussion_r4162576385


##########
datafusion/functions-aggregate/src/approx_distinct.rs:
##########
@@ -1355,6 +1377,61 @@ mod tests {
             );
             assert_eq!(distinct_count(&mut acc_single), 3);
         }
+
+        /// Grouped state (empty, sparse and dense rows) must merge into the
+        /// ungrouped accumulator.
+        #[test]
+        fn hll_acc_merges_grouped_state() {
+            let sparse = 10;
+            let dense = SPARSE_LIMIT * 4;
+            let values: ArrayRef = Arc::new(StringArray::from_iter_values(
+                (0..sparse + dense).map(|i| format!("value-{i}")),
+            ));
+            let group_indices: Vec<usize> = (0..sparse + dense)
+                .map(|i| if i < sparse { 1 } else { 2 })
+                .collect();
+
+            let mut grouped = HllGroupsAccumulator::new();
+            grouped
+                .update_batch(std::slice::from_ref(&values), &group_indices, 
None, 3)
+                .unwrap();
+            let state = grouped.state(EmitTo::All).unwrap();
+
+            let mut direct = HLLAccumulator::new();
+            direct.update_batch(std::slice::from_ref(&values)).unwrap();
+
+            let mut merged = HLLAccumulator::new();
+            merged.merge_batch(&state).unwrap();

Review Comment:
   This seems not to be the expected usage of accumulator 🤔



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to