You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "jonasdedden (via GitHub)" <gi...@apache.org> on 2026/09/24 11:25:54 UTC

[I] trunc(x) on a column turns -0.0 into 0.0 [datafusion]

jonasdedden opened a new issue, #25702:
URL: https://github.com/apache/datafusion/issues/25702

   `trunc(x)` drops the sign of `-0.0`, but only when it runs on a column. On a scalar, and for `trunc(x, 0)`, the sign is kept.
   
   ```sql
   SELECT trunc(column1), trunc(column1, 0) FROM (VALUES (CAST(-0.0 AS DOUBLE)));
   -- got:      0.0, -0.0
   -- expected: -0.0, -0.0
   ```
   
   The column code path returns `0.0` for either zero:
   
   ```rust
   if x == 0_f64 { 0_f64 } else { x.trunc() }
   ```
   
   `-0.0 == 0.0` is true, so `-0.0` becomes `0.0`. `f64::trunc` already keeps the sign, so plain `x.trunc()` would be enough.
   
   Seen through Lance (pylance 12.0.0): `trunc(x, 0)` on a `-0.0` column returns `-0.0`. This line is the same on `main` and in 55.1.0. I found no existing issue or PR for it.
   


-- 
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: github-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] trunc(x) on a column turns -0.0 into 0.0 [datafusion]

Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on issue #25702:
URL: https://github.com/apache/datafusion/issues/25702#issuecomment-5827398309

   take


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] trunc(x) on a column turns -0.0 into 0.0 [datafusion]

Posted by "adriangb (via GitHub)" <gi...@apache.org>.
adriangb closed issue #25702: trunc(x) on a column turns -0.0 into 0.0
URL: https://github.com/apache/datafusion/issues/25702


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org