minni31 opened a new pull request, #12777:
URL: https://github.com/apache/gluten/pull/12777

   ## What changes are proposed in this pull request?
   
   Spark's `ceiling(x, scale)` / `floor(x, scale)` on decimal inputs produce 
`RoundCeil(decimal, scale)` / `RoundFloor(decimal, scale)`. These expressions 
were mapped to the substrait `ceil` / `floor` function names via 
`ExpressionMappings`, but there was no native execution path for the 2-argument 
decimal form, so it silently fell back to vanilla Spark.
   
   This PR wires the 2-arg decimal forms to the Velox `decimal_ceil` / 
`decimal_floor` special forms:
   
   - **`SubstraitParser::mapToVeloxFunction`** gains a `numArgs` parameter 
(defaulting to `0`) and remaps 2-arg `ceil` / `floor` on decimals to 
`decimal_ceil` / `decimal_floor`. Unary `ceil(decimal)` / `floor(decimal)` keep 
their existing name and native path, so there is no change to the 1-arg 
behavior.
   - **`DecimalCeilFloorTransformer`** (new) mirrors the existing 
`DecimalRoundTransformer`: it recomputes the output `DecimalType` from the 
input decimal type and the constant-folded scale (matching Spark's 
`RoundBase.dataType`), and emits the scale as a literal argument.
   - **`ExpressionConverter`** routes decimal `RoundCeil` / `RoundFloor` 
through the new transformer, consistent with how decimal `Round` is handled.
   
   The ClickHouse path is unchanged: the substrait function names (`ceil` / 
`floor`) are preserved, so only the Velox backend remaps them on the C++ side.
   
   This addresses the `RoundCeil` / `RoundFloor` items tracked in #10134.
   
   ## How was this patch tested?
   
   Added a native offload test in `MathFunctionsValidateSuite` covering 2-arg 
`ceiling` / `floor` on decimal inputs with both positive and negative scales. 
It uses `runQueryAndCompare` (validates results against vanilla Spark) and 
asserts the projection is offloaded via 
`checkGlutenPlan[ProjectExecTransformer]`.
   
   ## Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: GitHub Copilot


-- 
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]

Reply via email to