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

fix: Flip order on right join #20358

Merged
merged 4 commits into from
Dec 19, 2024
Merged

Conversation

stijnherfst
Copy link
Collaborator

Fixes #20350

When doing a right join the dataframes were swapped and a left join was done. For this the maintain_order argument also needs to be flipped. Thanks @rodrigogiraoserrao for catching this.

@stijnherfst stijnherfst marked this pull request as ready for review December 19, 2024 08:41
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Dec 19, 2024
@@ -81,6 +81,18 @@ pub enum MaintainOrderJoin {
RightLeft,
}

impl MaintainOrderJoin {
pub fn flip(&self) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set this to minimal need publicity.

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 79.11%. Comparing base (6e4d717) to head (e8eea43).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-ops/src/frame/join/args.rs 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20358      +/-   ##
==========================================
- Coverage   79.13%   79.11%   -0.03%     
==========================================
  Files        1572     1572              
  Lines      219839   219929      +90     
  Branches     2462     2465       +3     
==========================================
+ Hits       173970   173992      +22     
- Misses      45301    45369      +68     
  Partials      568      568              

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

@ritchie46 ritchie46 merged commit e1d1b5f into pola-rs:main Dec 19, 2024
25 checks passed
@@ -1243,6 +1243,20 @@ def test_join_preserve_order_left() -> None:
5,
]

right_left = left.join(right, on="a", how="right", maintain_order="left").collect()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit odd to have tests for right joins in the test_join_preserve_order_left function, but oh well.
IMO the fact that the right join is implemented in terms of the left join is just a (clever) implementation detail.
Leaning on that was what led to this bug in the first place 😁

@alexander-beedie alexander-beedie added documentation Improvements or additions to documentation fix Bug fix and removed fix Bug fix documentation Improvements or additions to documentation labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Join's maintain_order not respected for right joins
4 participants