Skip to content

Conversation

mcrumiller
Copy link
Contributor

Partial fix for #22547.

This supercedes #24441 and only implements ignore_nulls for basic dtype expressions and group_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.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Sep 12, 2025
@mcrumiller mcrumiller force-pushed the first-non-null-expr branch 2 times, most recently from 3b16e47 to 4b7831c Compare September 12, 2025 17:46
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)
Copy link
Contributor Author

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?

@ritchie46 ritchie46 force-pushed the main branch 3 times, most recently from ddf5907 to d0914d4 Compare September 27, 2025 11:06
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant