From f4b9856799be7db65977e1247c1952550df1a055 Mon Sep 17 00:00:00 2001 From: ritchie Date: Sun, 14 Jul 2024 09:38:01 +0200 Subject: [PATCH 1/2] fix: Fix struct -> enum is_in --- crates/polars-ops/src/series/ops/is_in.rs | 3 +++ py-polars/tests/unit/operations/test_is_in.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/crates/polars-ops/src/series/ops/is_in.rs b/crates/polars-ops/src/series/ops/is_in.rs index cd773926fbdb..cbf900cf6f7b 100644 --- a/crates/polars-ops/src/series/ops/is_in.rs +++ b/crates/polars-ops/src/series/ops/is_in.rs @@ -506,6 +506,8 @@ fn is_in_struct(ca_in: &StructChunked, other: &Series) -> PolarsResult is_in_struct_array(ca_in, other), _ => { + let ca_in = ca_in.cast(&ca_in.dtype().to_physical()).unwrap(); + let ca_in = ca_in.struct_()?; let other = other.cast(&other.dtype().to_physical()).unwrap(); let other = other.struct_()?; @@ -526,6 +528,7 @@ fn is_in_struct(ca_in: &StructChunked, other: &Series) -> PolarsResult None: + df = pl.DataFrame() + dtype = pl.Enum(categories=["HBS"]) + df = df.insert_column(0, pl.Series("category", [], dtype=dtype)) + assert df.filter( + pl.struct("category").is_in( + pl.Series( + [{"category": "HBS"}], + dtype=pl.Struct({"category": df["category"].dtype}), + ) + ) + ).shape == (0, 1) From 70e0b2d588ce5d8dab0d81589c8584928363f779 Mon Sep 17 00:00:00 2001 From: ritchie Date: Sun, 14 Jul 2024 09:49:54 +0200 Subject: [PATCH 2/2] dbg --- crates/polars-ops/src/series/ops/is_in.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/polars-ops/src/series/ops/is_in.rs b/crates/polars-ops/src/series/ops/is_in.rs index cbf900cf6f7b..153eabc1a0c1 100644 --- a/crates/polars-ops/src/series/ops/is_in.rs +++ b/crates/polars-ops/src/series/ops/is_in.rs @@ -528,7 +528,6 @@ fn is_in_struct(ca_in: &StructChunked, other: &Series) -> PolarsResult