From fc62e15af1f5445d7a8361ef7a0e5ed5b8f9c43c Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitao" Date: Tue, 8 Mar 2022 11:30:19 +0000 Subject: [PATCH] Fixed error in computing min_max --- src/compute/aggregate/simd/packed.rs | 4 ++-- tests/it/compute/aggregate/min_max.rs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/compute/aggregate/simd/packed.rs b/src/compute/aggregate/simd/packed.rs index 7af9ac2a4e2..46cff5e047a 100644 --- a/src/compute/aggregate/simd/packed.rs +++ b/src/compute/aggregate/simd/packed.rs @@ -43,12 +43,12 @@ macro_rules! simd_ord_int { #[inline] fn max_lane(self, x: Self) -> Self { - self.max(x) + self.lanes_lt(x).select(x, self) } #[inline] fn min_lane(self, x: Self) -> Self { - self.min(x) + self.lanes_gt(x).select(x, self) } #[inline] diff --git a/tests/it/compute/aggregate/min_max.rs b/tests/it/compute/aggregate/min_max.rs index bd0ac99e3a5..babf5b9f539 100644 --- a/tests/it/compute/aggregate/min_max.rs +++ b/tests/it/compute/aggregate/min_max.rs @@ -202,3 +202,13 @@ fn test_binary_min_max_1() { assert_eq!(Some("a".as_bytes()), min_binary(&a)); assert_eq!(Some("b".as_bytes()), max_binary(&a)); } + +#[test] +fn test_max_not_lexi() { + let values = [0, 10, 0, 0, 0, 0, 0, 0, 1, 0]; + let arr = Int64Array::from_slice(&values); + + let maximum = 10; + let out = max_primitive(&arr).unwrap(); + assert_eq!(out, maximum); +}