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: Respect nulls_last parameter in aggregate sort_by #17249

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

mcrumiller
Copy link
Contributor

@mcrumiller mcrumiller commented Jun 27, 2024

Fixes #17243.

From the issue example:

df = pl.DataFrame({
    "a": [1, 10, 9, 3, 2, 4, 7, 5, 6, 8, None, None],
    "b": [1, 2, 3, 1, 4, 2, 3, 3, 2, 1, 1, 2],
})

pl.Config.set_tbl_rows(12)
print(df.select(pl.all().sort_by("a", nulls_last=True).over("b")))
shape: (12, 2)
┌──────┬─────┐
│ a    ┆ b   │
│ ---  ┆ --- │
│ i64  ┆ i64 │
╞══════╪═════╡
│ 1    ┆ 1   │
│ 4    ┆ 2   │
│ 5    ┆ 3   │
│ 3    ┆ 1   │
│ 2    ┆ 4   │
│ 6    ┆ 2   │
│ 7    ┆ 3   │
│ 9    ┆ 3   │
│ 10   ┆ 2   │
│ 8    ┆ 1   │
│ null ┆ 1   │
│ null ┆ 2   │
└──────┴─────┘

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Jun 27, 2024
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.84%. Comparing base (01a65f0) to head (69af2c9).

Files Patch % Lines
crates/polars-expr/src/expressions/sortby.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17249      +/-   ##
==========================================
+ Coverage   80.82%   80.84%   +0.02%     
==========================================
  Files        1466     1466              
  Lines      192324   192328       +4     
  Branches     2745     2745              
==========================================
+ Hits       155437   155486      +49     
+ Misses      36384    36339      -45     
  Partials      503      503              

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

@mcrumiller mcrumiller marked this pull request as ready for review June 27, 2024 16:20
@mcrumiller mcrumiller changed the title fix: nulls_last parameter is ignored in aggregate sort_by fix: respect nulls_last parameter in aggregate sort_by Jun 27, 2024
@ritchie46
Copy link
Member

Great, thanks!

@ritchie46 ritchie46 merged commit 7de1736 into pola-rs:main Jun 28, 2024
28 checks passed
@stinodego stinodego changed the title fix: respect nulls_last parameter in aggregate sort_by fix: Respect nulls_last parameter in aggregate sort_by Jun 30, 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.

sort_by("col", nulls_last=True).over("other") does not put nulls at the end
2 participants