fix(rust): Handle empty lists in list.agg with scalar aggregations#26424
Open
Zakir032002 wants to merge 3 commits intopola-rs:mainfrom
Open
fix(rust): Handle empty lists in list.agg with scalar aggregations#26424Zakir032002 wants to merge 3 commits intopola-rs:mainfrom
Zakir032002 wants to merge 3 commits intopola-rs:mainfrom
Conversation
Fixes pola-rs#26237 When list.agg() is called with mixed nulls and empty lists, empty groups may produce no values. This fix pads the result with nulls to match expected length before deposit().
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26424 +/- ##
=======================================
Coverage 81.01% 81.01%
=======================================
Files 1782 1782
Lines 243119 243130 +11
Branches 3078 3078
=======================================
+ Hits 196954 196972 +18
+ Misses 45362 45355 -7
Partials 803 803 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
orlp
requested changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #26237
When
list.agg()is used with scalar aggregations (such asfirst()) on columnscontaining a mix of nulls and empty lists, Polars may panic with an assertion
failure in
deposit().This occurs because scalar aggregations on empty lists can produce no output,
while
deposit()expects one value per valid group based on the validity bitmap,leading to a length mismatch.
This PR pads the aggregation result with null values when necessary so the number
of values matches the number of valid groups before calling
deposit().The fix is applied to functions:
evaluate_on_list_chunkedevaluate_on_array_chunkedAI disclosure
relevant, and consistent with the existing codebase.