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

refactor: Divide ChunkCompare into Eq and Ineq variants #18963

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

coastalwhite
Copy link
Collaborator

Divide the ChunkCompare trait into two traits ChunkCompareEq and ChunkCompareIneq, which allows us to statistically verify that there are no calls to the inequality methods when these are not available (e.g. for List, Array and Struct). This makes error handling a lot better as well.

For example, the following was a panic exception before.

import polars as pl

a = pl.Series('a', [[1]], pl.Array(pl.Int8, 1))
b = pl.Series('b', [[1]], pl.Array(pl.Int8, 1))

c = a < b

Now, it returns:

polars.exceptions.InvalidOperationError: cannot perform '<' comparison between series 'a' of dtype: array[i8, 1] and series 'b' of dtype: array[i8, 1]

Fixes #18938.

Divide the `ChunkCompare` trait into two traits `ChunkCompareEq` and
`ChunkCompareIneq`, which allows us to statistically verify that there are no
calls to the inequality methods when these are not available (e.g. for `List`,
`Array` and `Struct`). This makes error handling a lot better as well.

For example, the following was a panic exception before.

```python
import polars as pl

a = pl.Series('a', [[1]], pl.Array(pl.Int8, 1))
b = pl.Series('b', [[1]], pl.Array(pl.Int8, 1))

c = a < b
```

Now, it returns:

```
polars.exceptions.InvalidOperationError: cannot perform '<' comparison between series 'a' of dtype: array[i8, 1] and series 'b' of dtype: array[i8, 1]
```

Fixes pola-rs#18938.
@github-actions github-actions bot added internal An internal refactor or improvement python Related to Python Polars rust Related to Rust Polars labels Sep 27, 2024
Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 74.54545% with 14 lines in your changes missing coverage. Please review.

Project coverage is 79.85%. Comparing base (d097d3c) to head (592a874).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-core/src/frame/column/mod.rs 0.00% 8 Missing ⚠️
crates/polars-core/src/series/comparison.rs 79.31% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18963      +/-   ##
==========================================
+ Coverage   79.83%   79.85%   +0.01%     
==========================================
  Files        1523     1523              
  Lines      207296   207277      -19     
  Branches     2906     2906              
==========================================
+ Hits       165498   165514      +16     
+ Misses      41250    41215      -35     
  Partials      548      548              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ritchie46
Copy link
Member

Can you fix the link. Then it's good to go.

@ritchie46 ritchie46 merged commit 79fcd53 into pola-rs:main Sep 27, 2024
18 of 19 checks passed
@coastalwhite coastalwhite deleted the refactor/chunkcmp-to-eq-ineq branch September 27, 2024 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic when comparing Arrays
2 participants