Skip to content

Commit

Permalink
Add fast quit for numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrumiller committed Jan 4, 2025
1 parent de6240e commit e7e5a60
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/polars-ops/src/series/ops/horizontal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub fn min_horizontal(columns: &[Column]) -> PolarsResult<Option<Column>> {
}

// Return a full-null column with dtype determined by supertype of supplied columns.
// Name of returned column is the left-month input column.
// Name of returned column is the left-most input column.
fn null_with_supertype(columns: &[Column], date_to_datetime: bool) -> PolarsResult<Option<Column>> {
// We must first determine the correct return dtype.
let mut return_dtype = dtypes_to_supertype(columns.iter().map(|c| c.dtype()))?;
Expand Down Expand Up @@ -350,7 +350,10 @@ pub fn mean_horizontal(
// All remaining must be numeric (or null).
for col in &columns[first_non_null_idx + 1..] {
let dtype = col.dtype();
if !(dtype.is_numeric()
if !ignore_nulls && dtype == &DataType::Null {
// The presence of a single null column guarantees the output is all-null.
return null_with_supertype(columns, true);
} else if !(dtype.is_numeric()
|| dtype.is_decimal()
|| dtype.is_bool()
|| dtype.is_temporal()
Expand Down

0 comments on commit e7e5a60

Please sign in to comment.