From 087ac25b09f84ed3c50dc68edd479f6df9930725 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Thu, 26 Mar 2026 04:03:18 +0000 Subject: [PATCH] fix(partition): reject nan and infinity in expr split Signed-off-by: WenyXu --- src/partition/src/utils/split.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/partition/src/utils/split.rs b/src/partition/src/utils/split.rs index f4e363b3f0..ba5a538978 100644 --- a/src/partition/src/utils/split.rs +++ b/src/partition/src/utils/split.rs @@ -38,8 +38,6 @@ pub enum ExprSplitDegradeReason { UnsupportedNotExpansion, ColliderRejected, EmptyBranch, - ValidationFailed, - SimplifyFailed, } /// Splits one partition expression with a split predicate. @@ -458,12 +456,7 @@ fn validate_atomic(expr: &PartitionExpr) -> Result<()> { is_supported_value(v), error::InvalidExprSnafu { expr: expr.clone() } ); - if (is_nan_value(v) || is_infinite_value(v)) - && matches!( - expr.op(), - RestrictedOp::Lt | RestrictedOp::LtEq | RestrictedOp::Gt | RestrictedOp::GtEq - ) - { + if is_nan_value(v) || is_infinite_value(v) { return error::InvalidExprSnafu { expr: expr.clone() }.fail(); } Ok(()) @@ -1108,6 +1101,20 @@ mod tests { assert!(validate_supported_expr(&neg_inf).is_err()); } + #[test] + fn test_validate_supported_expr_nan_eq_rejected() { + let expr = col("a").eq(Value::Float64(OrderedFloat(f64::NAN))); + assert!(validate_supported_expr(&expr).is_err()); + } + + #[test] + fn test_validate_supported_expr_infinite_eq_rejected() { + let pos_inf = col("a").eq(Value::Float64(OrderedFloat(f64::INFINITY))); + let neg_inf = col("a").not_eq(Value::Float32(OrderedFloat(f32::NEG_INFINITY))); + assert!(validate_supported_expr(&pos_inf).is_err()); + assert!(validate_supported_expr(&neg_inf).is_err()); + } + #[test] fn test_simplify_and_bounds_or_keeps_original() { // OR tree is intentionally not flattened by AND-only simplifier.