viirya commented on code in PR #23913:
URL: https://github.com/apache/datafusion/pull/23913#discussion_r3667031579
##########
datafusion/functions-aggregate/src/percentile_cont.rs:
##########
@@ -713,7 +745,12 @@ where
let arr = values[0].as_primitive::<T>();
for value in arr.iter().flatten() {
- self.distinct_values.values.remove(&Hashable(value));
+ if let Some(count) = self.counts.get_mut(&Hashable(value)) {
+ *count -= 1;
+ if *count == 0 {
+ self.counts.remove(&Hashable(value));
+ }
+ }
Review Comment:
I left `retract_batch` silently skipping a value that isn't in the map
rather than erroring. The sliding-window executor only retracts values it
previously passed to `update_batch`, so a missing key shouldn't happen in
practice — but if it ever did (a bug elsewhere), erroring would turn a latent
inconsistency into a hard query failure, whereas skipping keeps the window's
remaining counts intact. I'm not strongly attached either way; if you'd prefer
a `debug_assert!` (catches it in tests/debug builds without failing production
queries), I'm happy to add that instead. What do you think?
--
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]