westonpace commented on code in PR #10627:
URL: https://github.com/apache/datafusion/pull/10627#discussion_r1631196582


##########
datafusion/physical-expr/src/aggregate/min_max.rs:
##########
@@ -1103,3 +1117,36 @@ impl Accumulator for SlidingMinAccumulator {
         std::mem::size_of_val(self) - std::mem::size_of_val(&self.min) + 
self.min.size()
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn float_max_with_nans() {
+        let pos_nan = f32::NAN;
+        let zero = 0_f32;
+
+        let vals_float = Float32Array::from_iter_values([zero, 
pos_nan].iter().copied());
+
+        let vals: ArrayRef = Arc::new(vals_float.clone());
+
+        // We accumulate the above two rows in two different ways.  First, we 
pass in both as a single batch
+        let mut accumulator = 
MaxAccumulator::try_new(&DataType::Float32).unwrap();
+        accumulator.update_batch(&[vals]).unwrap();
+        let single_batch_result = &accumulator.evaluate().unwrap();
+
+        // Next we pass the two values in two different batches.
+        let vals_a: ArrayRef =
+            
Arc::new(Float32Array::from_iter_values([pos_nan].iter().copied()));
+        let vals_b: ArrayRef =
+            Arc::new(Float32Array::from_iter_values([zero].iter().copied()));
+
+        let mut accumulator = 
MaxAccumulator::try_new(&DataType::Float32).unwrap();
+        accumulator.update_batch(&[vals_a]).unwrap();
+        accumulator.update_batch(&[vals_b]).unwrap();
+        let split_batch_result = &accumulator.evaluate().unwrap();
+
+        assert_eq!(single_batch_result, split_batch_result);

Review Comment:
   Thanks for the suggestions, I have updated the test to check both.



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to