Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

trunc(x) on a column turns -0.0 into 0.0

Open Beginner friendly
#25,702 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@1fanwang is already working on this.

Since Sep 25, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust, sql
Domain
databases

Research direction

Look for the trunc function implementation in the DataFusion codebase, likely in a file like expr/scalar.rs or expr/builtin.rs. The bug is in the columnar path where x == 0_f64 is used. Replace that condition with a check that preserves the sign, perhaps using x.trunc() directly. Write a test in the corresponding test module to verify trunc(-0.0) returns -0.0 for a column. Run the existing SQL function tests to ensure no regressions.

Written by the indexing model from the issue text.

Description

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.

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:

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.

Dominant language
Rust
Stars
9.4k
Forks
2.5k
Avg merge
3d 17h
Merged PRs (30d)
383

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/datafusion

All issues in apache/datafusion

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.