ump45nose opened a new pull request, #26914: URL: https://github.com/apache/datafusion/pull/26914
## Which issue does this PR close? - Closes #21560. ## Rationale for this change Spark `ceil` / `ceiling` accepts a second scale argument (`RoundCeil`). Only the one-arg form was implemented in `datafusion-spark`, and the matching cases in `ceil.slt` were commented out with a TODO pointing at this issue. Earlier attempts (#21562, #21710, #24643) did not land. This PR focuses on the decimal path Spark declares for `RoundCeil`, and treats overflow as an error instead of wrapping (Spark raises `NUMERIC_VALUE_OUT_OF_RANGE` for extreme negative scales). ## What changes are included in this PR? - `SparkCeil` accepts `ceil(decimal, Int32 scale)` with a constant scale. - Result type follows Spark `RoundBase::dataType` via `return_field_from_args`. - Checked arithmetic + precision check so results cannot silently wrap past the declared Decimal128 precision. - Re-enable the two PySpark-backed cases in `ceil.slt`. The positive-scale case uses the `ceiling` alias because sqlparser still routes `ceil(x, 3)` through `CeilFloorKind::Scale`, which the planner rejects before UDF resolution (same as today for FLOOR). Non-decimal inputs with a scale are left for a follow-up (Spark casts them to decimal first). ## What is the testing strategy for this PR? - Unit tests in `ceil.rs` for the PySpark cases, rounding toward +∞, no-op scales, carry, precision bounds, and overflow errors. - `cargo test -p datafusion-spark --lib function::math::ceil` - `cargo test -p datafusion-sqllogictest --test sqllogictests -- spark/math/ceil` ## Are there any user-facing changes? Spark sessions gain working `ceil`/`ceiling` with a decimal scale argument. No change to DataFusion's built-in one-arg `ceil`. ## AI assistance Assisted by AI tooling for drafting and iterating; I reviewed the Spark `RoundCeil` / `RoundBase` semantics, the overflow cases called out on #24643, and the test results before opening this PR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
