Skip to content

-0.0 == 0.0 is false, so filters, joins and group-bys split zero in two #7656

Open

Description

@RyanLin5967

Describe the bug

Currently, float equality goes through arrow-rs cmp::eq (DataArray::equal in src/daft-core/src/array/ops/comparison.rs), which compares by IEEE 754 totalOrder, where -0.0 and 0.0 are different values. So col("f") == 0.0 misses rows holding -0.0, an equi-join on a float key does not match -0.0 with 0.0, and groupby/distinct return two zero groups. IEEE 754 equality, Python, DuckDB and polars all treat the two as equal, and PyIceberg, polars and DuckDB return the -0.0 row for f = 0.0 on the same Iceberg table that daft.read_iceberg filters it out of.

To Reproduce

import daft

df = daft.from_pydict({"f": [-0.0, 0.0, 1.0]})
print(df.where(daft.col("f") == 0.0).to_pydict())
# {'f': [0.0]}
print(daft.sql("SELECT f FROM df WHERE f = 0.0").to_pydict())
# {'f': [0.0]}
print(df.distinct().count_rows())
# 3

a = daft.from_pydict({"k": [-0.0]})
b = daft.from_pydict({"k": [0.0], "v": [1]})
print(a.join(b, on="k").to_pydict())
# {'k': [], 'v': []}

Expected behavior

{'f': [-0.0, 0.0]} for both filters, 2 distinct values, and one joined row {'k': [-0.0], 'v': [1]} (or 0.0), as -0.0 == 0.0 in Python and SELECT CAST(-0.0 AS DOUBLE) = 0.0 in DuckDB.

Component(s)

Built-in Functions

Additional context

daft 0.7.26, Python 3.12.13, macOS 26.6.2, arm64 (Darwin 25.6.0). DataArray::equal and compare_to_scalar still call cmp::eq on main.

Activity

  1. added
    bug
    on Oct 30, 2026
  2. hello-peter-tang commented on Oct 30, 2026

    @hello-peter-tang
    Contributor

    I'd like to take this one. I'll investigate and open a PR with a fix and a regression test.

  3. hello-peter-tang commented on Oct 30, 2026

    @hello-peter-tang
    Contributor

    Opened #7661 with the fix and a Python regression test covering filters, joins, group-by, and distinct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugexpressionneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions