Compute MIN of a numeric column using Arrow SIMD kernels.
(batch: &RecordBatch, column_name: &str)
| 186 | |
| 187 | /// Compute MIN of a numeric column using Arrow SIMD kernels. |
| 188 | pub fn arrow_min(batch: &RecordBatch, column_name: &str) -> Option<f64> { |
| 189 | let idx = batch.schema().index_of(column_name).ok()?; |
| 190 | let array = batch.column(idx); |
| 191 | |
| 192 | if let Some(f64_arr) = array.as_any().downcast_ref::<Float64Array>() { |
| 193 | arrow::compute::kernels::aggregate::min(f64_arr) |
| 194 | } else if let Some(i64_arr) = array.as_any().downcast_ref::<Int64Array>() { |
| 195 | arrow::compute::kernels::aggregate::min(i64_arr).map(|v| v as f64) |
| 196 | } else { |
| 197 | None |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /// Compute MAX of a numeric column using Arrow SIMD kernels. |
| 202 | pub fn arrow_max(batch: &RecordBatch, column_name: &str) -> Option<f64> { |