From 39f7b1aa8c5d0e21cc610bb0eac8497e02746495 Mon Sep 17 00:00:00 2001 From: coastalwhite Date: Wed, 18 Sep 2024 15:10:59 +0200 Subject: [PATCH] fix: Throw error for comparison of unequal length series --- crates/polars-core/src/series/comparison.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/polars-core/src/series/comparison.rs b/crates/polars-core/src/series/comparison.rs index 6ccb4db7c219..b632880b50d4 100644 --- a/crates/polars-core/src/series/comparison.rs +++ b/crates/polars-core/src/series/comparison.rs @@ -10,6 +10,8 @@ macro_rules! impl_compare { let (lhs, rhs) = ($self, $rhs); validate_types(lhs.dtype(), rhs.dtype())?; + polars_ensure!(lhs.len() == rhs.len(), ShapeMismatch: "could not compare between two series of different length ({} != {})", lhs.len(), rhs.len()); + #[cfg(feature = "dtype-categorical")] match (lhs.dtype(), rhs.dtype()) { (Categorical(_, _) | Enum(_, _), Categorical(_, _) | Enum(_, _)) => {