(input: &Arc<dyn arrow::array::Array>)
| 142 | } |
| 143 | |
| 144 | fn spark_ceil_array(input: &Arc<dyn arrow::array::Array>) -> Result<ColumnarValue> { |
| 145 | let result = match input.data_type() { |
| 146 | DataType::Float32 => Arc::new( |
| 147 | input |
| 148 | .as_primitive::<Float32Type>() |
| 149 | .unary::<_, Int64Type>(|x| x.ceil() as i64), |
| 150 | ) as _, |
| 151 | DataType::Float64 => Arc::new( |
| 152 | input |
| 153 | .as_primitive::<Float64Type>() |
| 154 | .unary::<_, Int64Type>(|x| x.ceil() as i64), |
| 155 | ) as _, |
| 156 | dt if dt.is_integer() => arrow::compute::cast(input, &DataType::Int64)?, |
| 157 | DataType::Decimal128(p, s) if *s > 0 => { |
| 158 | let new_p = decimal128_ceil_precision(*p, *s); |
| 159 | let result: Decimal128Array = input |
| 160 | .as_primitive::<Decimal128Type>() |
| 161 | .unary(|x| decimal128_ceil(x, *s as u32)); |
| 162 | Arc::new(result.with_data_type(DataType::Decimal128(new_p, 0))) |
| 163 | } |
| 164 | DataType::Decimal128(_, _) => Arc::clone(input), |
| 165 | other => return exec_err!("Unsupported data type {other:?} for function ceil"), |
| 166 | }; |
| 167 | |
| 168 | Ok(ColumnarValue::Array(result)) |
| 169 | } |
| 170 | |
| 171 | #[cfg(test)] |
| 172 | mod tests { |
no test coverage detected
searching dependent graphs…