From 4126c019a1202db4af3a86e4ff1b57179cc80b49 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Thu, 14 Mar 2024 11:19:09 +0100 Subject: [PATCH] WIP --- crates/polars-core/src/chunked_array/cast.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/polars-core/src/chunked_array/cast.rs b/crates/polars-core/src/chunked_array/cast.rs index a0d18bd5c7da..976dd568ddc4 100644 --- a/crates/polars-core/src/chunked_array/cast.rs +++ b/crates/polars-core/src/chunked_array/cast.rs @@ -384,7 +384,7 @@ impl ChunkCast for ListChunked { (dt, Categorical(None, _) | Enum(_, _)) if !matches!(dt, Categorical(_, _) | Enum(_, _) | String | Null) => { - polars_bail!(ComputeError: "cannot cast List inner type: '{:?}' to Categorical", dt) + polars_bail!(InvalidOperation: "cannot cast List inner type: '{:?}' to Categorical", dt) }, _ => { // ensure the inner logical type bubbles up @@ -418,7 +418,7 @@ impl ChunkCast for ListChunked { }, _ => { polars_bail!( - ComputeError: "cannot cast List type (inner: '{:?}', to: '{:?}')", + InvalidOperation: "cannot cast List type (inner: '{:?}', to: '{:?}')", self.inner_dtype(), data_type, ) @@ -452,7 +452,7 @@ impl ChunkCast for ArrayChunked { (old, new) if old == *new => Ok(self.clone().into_series()), #[cfg(feature = "dtype-categorical")] (dt, Categorical(None, _) | Enum(_, _)) if !matches!(dt, String) => { - polars_bail!(InvalidOperation: "cannot cast fixed-size-list inner type: '{:?}' to dtype: {:?}", dt, child_type) + polars_bail!(InvalidOperation: "cannot cast Array inner type: '{:?}' to dtype: {:?}", dt, child_type) }, _ => { // ensure the inner logical type bubbles up @@ -483,7 +483,13 @@ impl ChunkCast for ArrayChunked { )) } }, - _ => polars_bail!(InvalidOperation: "cannot cast list type"), + _ => { + polars_bail!( + InvalidOperation: "cannot cast Array type (inner: '{:?}', to: '{:?}')", + self.inner_dtype(), + data_type, + ) + }, } }