akurmustafa commented on code in PR #13554:
URL: https://github.com/apache/datafusion/pull/13554#discussion_r1861087905


##########
datafusion/functions-aggregate/src/median.rs:
##########
@@ -310,6 +310,19 @@ impl<T: ArrowNumericType> Accumulator for 
DistinctMedianAccumulator<T> {
     }
 }
 
+/// Get maximum entry in the slice,
+fn slice_max<T>(array: &[T::Native]) -> T::Native
+where
+    T: ArrowPrimitiveType,
+    T::Native: PartialOrd, // Ensure the type supports PartialOrd for 
comparison
+{
+    // Make sure that, array is not empty.
+    debug_assert!(!array.is_empty());
+    array
+        .iter()
+        .fold(array[0], |max, &val| if max > val { max } else { val })
+}

Review Comment:
   I am not sure we can, at least I couldn't make it work. However, maybe I am 
missing something. By the way, following is the trait description for 
`ArrowPrimitiveType::Native`
   ```rust
   pub trait ArrowNativeType:
       std::fmt::Debug + Send + Sync + Copy + PartialOrd + Default + 
private::Sealed + 'static
   {
   ```
   and signature of `max` is as follows:
   ```rust
       fn max(self) -> Option<Self::Item>
       where
           Self: Sized,
           Self::Item: Ord,
       {
           self.max_by(Ord::cmp)
       }
   ```



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