Skip to content

Commit

Permalink
check_for_invalid_stats_in_isnull
Browse files Browse the repository at this point in the history
  • Loading branch information
deanm0000 committed Jun 6, 2024
1 parent 8370e3c commit 07a301c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions crates/polars-expr/src/expressions/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use polars_core::POOL;
use polars_io::predicates::{BatchStats, StatsEvaluator};
#[cfg(feature = "is_between")]
use polars_ops::prelude::ClosedInterval;
use polars_utils::min_max;
use rayon::prelude::*;

use super::*;
Expand Down Expand Up @@ -524,9 +525,22 @@ impl ApplyExpr {
let root = expr_to_leaf_column_name(&self.expr)?;

match stats.get_stats(&root).ok() {
Some(st) => match st.null_count() {
Some(0) => Ok(false),
_ => Ok(true),
Some(st) => {
let invalid = match (st.to_min(), st.to_max()) {
(Some(min), Some(max)) => {
ChunkCompare::gt(min,max).ok().unwrap().all()
},
_ => true,
};
if invalid {
polars_warn!("The min_value stat is greater than max_value. \
Ignoring stats as invalid"
);
};
match (st.null_count(), invalid) {
(Some(0), false) => Ok(false),
_ => Ok(true),
}
},
None => Ok(true),
}
Expand Down

0 comments on commit 07a301c

Please sign in to comment.