MCPcopy Create free account
hub / github.com/apache/datafusion / spark_ceil_array

Function spark_ceil_array

datafusion/spark/src/function/math/ceil.rs:144–169  ·  view source on GitHub ↗
(input: &Arc<dyn arrow::array::Array>)

Source from the content-addressed store, hash-verified

142}
143
144fn 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)]
172mod tests {

Callers 1

spark_ceilFunction · 0.85

Calls 8

newFunction · 0.85
decimal128_ceilFunction · 0.85
is_integerMethod · 0.80
with_data_typeMethod · 0.80
castFunction · 0.50
Decimal128Class · 0.50
data_typeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…