Skip to content

Commit 2d6fc51

Browse files
Add examples for min and max functions (#9062)
# Which issue does this PR close? - Closes #9055. # What changes are included in this PR? Changes to docstrings for `min` and `max` functions. # Are these changes tested? Yes # Are there any user-facing changes? Yes. These doc pages will be updated: https://docs.rs/arrow/latest/arrow/compute/fn.min.html https://docs.rs/arrow/latest/arrow/compute/fn.max.html
1 parent 814ee42 commit 2d6fc51

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

arrow-arith/src/aggregate.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,15 @@ where
809809

810810
/// Returns the minimum value in the array, according to the natural order.
811811
/// For floating point arrays any NaN values are considered to be greater than any other non-null value
812+
///
813+
/// # Example
814+
/// ```rust
815+
/// # use arrow_array::Int32Array;
816+
/// # use arrow_arith::aggregate::min;
817+
/// let array = Int32Array::from(vec![8, 2, 4]);
818+
/// let result = min(&array);
819+
/// assert_eq!(result, Some(2));
820+
/// ```
812821
pub fn min<T: ArrowNumericType>(array: &PrimitiveArray<T>) -> Option<T::Native>
813822
where
814823
T::Native: PartialOrd,
@@ -818,6 +827,15 @@ where
818827

819828
/// Returns the maximum value in the array, according to the natural order.
820829
/// For floating point arrays any NaN values are considered to be greater than any other non-null value
830+
///
831+
/// # Example
832+
/// ```rust
833+
/// # use arrow_array::Int32Array;
834+
/// # use arrow_arith::aggregate::max;
835+
/// let array = Int32Array::from(vec![4, 8, 2]);
836+
/// let result = max(&array);
837+
/// assert_eq!(result, Some(8));
838+
/// ```
821839
pub fn max<T: ArrowNumericType>(array: &PrimitiveArray<T>) -> Option<T::Native>
822840
where
823841
T::Native: PartialOrd,

0 commit comments

Comments
 (0)