Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy join_where between Int64 and UInt64 attempts cast to Float64 and fails with SchemaError #21052

Closed
2 tasks done
nameexhaustion opened this issue Feb 3, 2025 · 2 comments · Fixed by #21049
Closed
2 tasks done
Assignees
Labels
accepted Ready for implementation bug Something isn't working python Related to Python Polars

Comments

@nameexhaustion
Copy link
Collaborator

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

(
    pl.Series([1], dtype=pl.Int64)
    .to_frame()
    .lazy()
    .join_where(
        pl.Series([1], dtype=pl.UInt64).to_frame().lazy(),
        pl.col("") == pl.col("_right"),
    )
    .collect()
)

Log output

polars.exceptions.SchemaError: datatypes of join keys don't match - ``: f64 on left does not match ``: u64 on right

Issue description

There is a cast to Float64 being inserted somewhere that should not be inserted. This should instead cast to Int128.

Expected behavior

Succeeds without failing

Installed versions

1.21.0

@nameexhaustion nameexhaustion added bug Something isn't working python Related to Python Polars labels Feb 3, 2025
@nameexhaustion nameexhaustion self-assigned this Feb 3, 2025
@lukemanley
Copy link
Contributor

It looks like this occurs here:

(Int64, UInt64) => Some(Float64), // Follow numpy

Here is a related example where adding an Int64 and a UInt64 results in a Float64 rather than a Int128:

pl.select(pl.lit(1, pl.Int64) + pl.lit(1, pl.UInt64))

# shape: (1, 1)
# ┌─────────┐
# │ literal │
# │ ---     │
# │ f64     │
# ╞═════════╡
# │ 2.0     │
# └─────────┘

Would changing this to return Int128 be considered a breaking change?

@nameexhaustion nameexhaustion added regression Issue introduced by a new release and removed regression Issue introduced by a new release labels Feb 4, 2025
@nameexhaustion
Copy link
Collaborator Author

nameexhaustion commented Feb 4, 2025

Nice debugging

Would changing this to return Int128 be considered a breaking change?

I am in favor of doing this, but I would also consider it a breaking change as it would change the behavior of some queries.

We don't need to change it to fix the current issue - type coercion of join keys should not be hitting that codepath.

@nameexhaustion nameexhaustion changed the title SchemaError on lazy join_where between Int64 and UInt64 Lazy join_where between Int64 and UInt64 attempts to cast to Float64 and fails with SchemaError Feb 5, 2025
@nameexhaustion nameexhaustion changed the title Lazy join_where between Int64 and UInt64 attempts to cast to Float64 and fails with SchemaError Lazy join_where between Int64 and UInt64 attempts cast to Float64 and fails with SchemaError Feb 5, 2025
@c-peters c-peters added the accepted Ready for implementation label Feb 10, 2025
@c-peters c-peters added this to Backlog Feb 10, 2025
@c-peters c-peters moved this to Done in Backlog Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working python Related to Python Polars
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants