Skip to content

bug: -0.0 and 0.0 still compare unequal between columns and in array_has #9316

Description

@jonasdedden

Description

#6236 (fixing #5868) makes filters treat -0.0 and 0.0 as the same value when one side is a literal. Comparisons between two float values, and array_has with a zero, still compare by encoding:

Steps to reproduce

import lance
import pyarrow as pa

data = pa.table({
    "id": [0, 1, 2],
    "a": [-0.0, 0.0, 1.0],
    "b": [0.0, -0.0, 1.0],
    "l": [[-0.0], [0.0], [1.0]],
})
ds = lance.write_dataset(data, "zero.lance", mode="overwrite")

def ids(filter):
    return sorted(ds.to_table(columns=["id"], filter=filter)["id"].to_pylist())

print("a = 0.0            ", ids("a = 0.0"))   # fixed by #6236
print("a = b              ", ids("a = b"))
print("a < b              ", ids("a < b"))
print("array_has(l, 0.0)  ", ids("array_has(l, 0.0)"))
print("array_has(l, -0.0) ", ids("array_has(l, -0.0)"))

On pylance 13.0.0b4:

a = 0.0             [0, 1]
a = b               [2]
a < b               [0]
array_has(l, 0.0)   [1]
array_has(l, -0.0)  [0]

Expected behavior

a = b               [0, 1, 2]
a < b               []
array_has(l, 0.0)   [0, 1]
array_has(l, -0.0)  [0, 1]

Lance version

13.0.0b4

Language binding

Python

Logs / traceback

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions