Skip to content

[Bug]: -2**63 // -1 inconsistent across backends, SQLFrame silently returns a float #4071

Open

Description

@ReguiguiMohamed

Describe the bug

Follow-up from #3994 as suggested by @FBruzzesi. Related to #2748.

The value -2**63 // -1 overflows int64, which backends handle in different ways. Polars, pandas and Dask wrap around to -2**63. pyarrow and DuckDB raise an overflow error, and ibis raises a conversion error. Finally, SQLFrame returns 9.223372036854776e+18 as a float with no error.

I think the SQLFrame one is the result I'd worry about most, since it's silently wrong.

Steps or code to reproduce the bug

Simply running a file like this is enough to see the bug:

import narwhals as nw
import polars as pl
from sqlframe.duckdb import DuckDBSession

expr = nw.col("a") // nw.col("b")
print(nw.from_native(pl.DataFrame({"a": [-(2**63)], "b": [-1]})).select(r=expr)["r"].to_list())

df = DuckDBSession().createDataFrame([(-(2**63), -1)], ["a", "b"])
print(nw.from_native(df).select(r=expr).collect()["r"].to_list())

Expected results

I'm not sure which behaviour narwhals is expected to adhere to here. Wrapping would match Polars, and raising is what pyarrow and DuckDB do. But either way SQLFrame shouldn't be returning a float.

Actual results

[-9223372036854775808]
[9.223372036854776e+18]

Across all backends (narwhals main 455269e):

backend -2**63 // -1
polars, pandas, pandas[nullable], dask -9223372036854775808
pandas[pyarrow], pyarrow ArrowInvalid: overflow
duckdb OutOfRangeException: Overflow in division of -9223372036854775808 / -1
ibis ConversionException: Type DOUBLE with value 9.223372036854776e+18 can't be cast
sqlframe 9.223372036854776e+18

Please run narwhals.show_versions() and enter the output below.

Python dependencies:
     narwhals: 2.26.0
        numpy: 2.5.3
       pandas: 3.0.6
        modin: 
         cudf: 
      pyarrow: 25.0.1
      pyspark: 
       polars: 1.44.2
         dask: 2026.8.0
       duckdb: 1.5.5
         ibis: 12.0.0
     sqlframe: 4.4.0

Relevant log output

Activity

  1. changed the title [-][Bug]: '-2**63 // -1' inconsistent across backends, SQLFrame silently returns a float[/-] [+][Bug]: `-2**63 // -1` inconsistent across backends, SQLFrame silently returns a float[/+] on Oct 13, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions