jackylee-ch commented on code in PR #25694:
URL: https://github.com/apache/datafusion/pull/25694#discussion_r4271295874


##########
datafusion/functions-aggregate/src/count.rs:
##########
@@ -1204,4 +1205,45 @@ mod tests {
         assert_eq!(merged.evaluate()?, ScalarValue::Int64(Some(3)));
         Ok(())
     }
+
+    #[test]

Review Comment:
   Added an end-to-end case in `physical_optimizer/aggregate_statistics.rs`: a 
statistics provider pops the trailing column entry on every scan, so the index 
stays out of bounds, and `SELECT count(b)` over data with a NULL and a 
duplicate returns 3 — it panics on main.
   
   `COUNT(DISTINCT b)` can't be reached that way: `SingleDistinctToGroupBy` 
rewrites it into a `GROUP BY b`, which panics earlier in 
`AggregateExec::statistics_inner` on the same unguarded pattern — a separate 
access, not this PR. The distinct branch now also has a short-statistics case 
in `test_count_distinct_optimization`.
   



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