1fanwang opened a new pull request, #25732:
URL: https://github.com/apache/datafusion/pull/25732

   ## Which issue does this PR close?
   
   - Closes https://github.com/apache/datafusion/issues/25702.
   
   ## Rationale for this change
   
   @jonasdedden reported that `trunc(column)` changes `-0.0` to `0.0` on the 
array path, while scalar `trunc(-0.0)` and `trunc(column, 0)` keep the sign. 
That makes the one-argument column form behave differently from the scalar form 
and from the explicit precision form.
   
   After this change, the one-argument Float32 and Float64 array paths use the 
native `trunc()` result directly. The SQL path now keeps the sign of negative 
zero instead of replacing it with positive zero.
   
   ## What changes are included in this PR?
   
   The Float32 and Float64 one-argument array implementation now matches Rust's 
`trunc()` behavior for zero values. The added unit test covers the lower 
function path for both float widths, and the sqllogictest case covers the SQL 
path through reciprocal infinity.
   
   ## What is the testing strategy for this PR?
   
   The original query fails on `main` and passes with this patch:
   
   ```text
   SELECT trunc(column1), trunc(column1, 0)
   FROM (VALUES (CAST(-0.0 AS DOUBLE)));
   
   main:  | 0.0  | -0.0 |
   fixed: | -0.0 | -0.0 |
   ```
   
   The regression tests pass:
   
   ```text
   $ cargo test --profile ci -p datafusion-functions trunc
   running 16 tests
   ...
   test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 384 filtered out
   
   $ cargo test --profile ci --test sqllogictests -- math.slt
   Progress: 1/1 files completed (100%)
   ```
   
   ## Are there any user-facing changes?
   
   Yes. `trunc(column)` now preserves the sign of `-0.0` for Float32 and 
Float64 inputs.
   


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