-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: Add ignore_nulls
to first
/last
#24455
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
Draft
mcrumiller
wants to merge
8
commits into
pola-rs:main
Choose a base branch
from
mcrumiller:first-non-null-expr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
3b16e47
to
4b7831c
Compare
mcrumiller
commented
Sep 12, 2025
Comment on lines
65
to
81
let indices = if ignore_nulls && s.null_count() != 0 { | ||
let null_s = s.is_null(); | ||
let null_values = null_s.downcast_as_array(); | ||
groups | ||
.iter() | ||
.map(|(_, idx)| { | ||
let mut this_idx = None; | ||
for &ii in idx.iter() { | ||
// SAFETY: null_values has no no values | ||
if !null_values.value_unchecked(ii as usize) { | ||
this_idx = Some(ii); | ||
break; | ||
} | ||
} | ||
this_idx | ||
}) | ||
.collect_ca(PlSmallStr::EMPTY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coastalwhite is this more what you had in mind?
7b7941a
to
7758e09
Compare
7758e09
to
0d76036
Compare
ddf5907
to
d0914d4
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or an improvement of an existing feature
python
Related to Python Polars
rust
Related to Rust Polars
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.
Partial fix for #22547.
This supercedes #24441 and only implements
ignore_nulls
for basic dtype expressions andgroup_by
, and does not include list/array dtypes. The next PR will tackle list/array.This PR touches a lot of files because there are many existing calls to first that had to be updated with the new parameter. An alternative that would leave more of the codebase untouched would be to add new expressions first_non_null and last_non_null. Let me know if you think this would be preferable.
Drafting this until I can figure out the streaming part of first/last.