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

feat: Raise on invalid 'is_between' and improve error message quality #18147

Merged
merged 4 commits into from
Aug 12, 2024

Conversation

ritchie46
Copy link
Member

@ritchie46 ritchie46 commented Aug 12, 2024

Set up architecture to catch non-sensical/ambiguous queries and raise an error asking for explicit casts.

In direct comparisons <, >, ==, >= and the likes, we already raised. For functions we didn't have the logic implemented yet. This will prevent a lot of trip ups where people think they compare dates, but instead are comparing string ascii values on order, which is never what you want to happen implicitly.

>>> pl.select(pl.lit(2).is_between(pl.lit("11"), pl.lit("33")))
InvalidOperationError: got invalid or ambiguous dtypes: '[dyn int, str, str]' in expression 'is_between'

Consider explicitly casting your input types to resolve ambiguity.

closes #18144

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Aug 12, 2024
@ritchie46 ritchie46 merged commit 8c19d18 into main Aug 12, 2024
25 checks passed
@ritchie46 ritchie46 deleted the is_between branch August 12, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not cast to supertypes for is_between
1 participant