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: Incorrect aggregation of empty groups after slice #20127

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

nameexhaustion
Copy link
Collaborator

Returned previously filtered values instead of NULL.

Fixes #20115

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Dec 3, 2024
@@ -110,6 +110,11 @@ impl PhysicalExpr for SliceExpr {
.collect::<PolarsResult<Vec<_>>>()
})?;
let mut ac = results.pop().unwrap();

if ac.is_aggregated() {
polars_bail!(InvalidOperation: "cannot slice() an aggregated value")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

drive-by - I noticed we currently silently ignore slice() after aggregations - I've made this raise instead.

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.53%. Comparing base (0263868) to head (0f27907).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20127      +/-   ##
==========================================
+ Coverage   79.52%   79.53%   +0.01%     
==========================================
  Files        1563     1563              
  Lines      217184   217194      +10     
  Branches     2465     2465              
==========================================
+ Hits       172706   172739      +33     
+ Misses      43917    43894      -23     
  Partials      561      561              

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

@@ -657,7 +657,8 @@ impl Column {
let mut s = scalar_col.take_materialized_series().rechunk();
// SAFETY: We perform a compute_len afterwards.
let chunks = unsafe { s.chunks_mut() };
chunks[0].with_validity(Some(validity));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this function isn't in-place and we didn't assign back 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

Auch...

@ritchie46 ritchie46 merged commit c5a8efa into pola-rs:main Dec 3, 2024
25 checks passed
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.

first(), last() list operations on a slice wrongly ignore the slice during aggregation
3 participants