Compute MAX of a numeric column using Arrow SIMD kernels.
(batch: &RecordBatch, column_name: &str)
| 200 | |
| 201 | /// Compute MAX of a numeric column using Arrow SIMD kernels. |
| 202 | pub fn arrow_max(batch: &RecordBatch, column_name: &str) -> Option<f64> { |
| 203 | let idx = batch.schema().index_of(column_name).ok()?; |
| 204 | let array = batch.column(idx); |
| 205 | |
| 206 | if let Some(f64_arr) = array.as_any().downcast_ref::<Float64Array>() { |
| 207 | arrow::compute::kernels::aggregate::max(f64_arr) |
| 208 | } else if let Some(i64_arr) = array.as_any().downcast_ref::<Int64Array>() { |
| 209 | arrow::compute::kernels::aggregate::max(i64_arr).map(|v| v as f64) |
| 210 | } else { |
| 211 | None |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | /// Compute COUNT of non-null values in a column. |
| 216 | pub fn arrow_count(batch: &RecordBatch, column_name: &str) -> Option<usize> { |