EeshanBembi commented on code in PR #21782:
URL: https://github.com/apache/datafusion/pull/21782#discussion_r3130148765


##########
datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs:
##########
@@ -85,11 +85,13 @@ where
         }
 
         let arr = as_primitive_array::<T>(&values[0])?;
-        arr.iter().for_each(|value| {
-            if let Some(value) = value {
+        if arr.null_count() > 0 {

Review Comment:
   Nit: a short comment here clarifies why the per-batch `null_count` check is 
correct even when earlier batches had nulls:
   
   ```rust
   // Fast path: no nulls in this batch, skip per-element validity checks.
   // Earlier batches with nulls are already handled; the HashSet union is 
correct
   // regardless of insertion order.
   if arr.null_count() == 0 { ... }
   ```



##########
datafusion/functions-aggregate-common/src/aggregate/count_distinct/native.rs:
##########
@@ -85,11 +85,13 @@ where
         }
 
         let arr = as_primitive_array::<T>(&values[0])?;
-        arr.iter().for_each(|value| {
-            if let Some(value) = value {
+        if arr.null_count() > 0 {

Review Comment:
   The benchmarks only generate `Some(...)` values. Please consider adding a 
variant with ~10% nulls to confirm the slow path (the `null_count > 0` branch) 
doesn't regress — that's a common production workload.



-- 
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