diff --git a/crates/polars-core/src/chunked_array/builder/boolean.rs b/crates/polars-core/src/chunked_array/builder/boolean.rs index 407bc3abcf53..7723802dd0ac 100644 --- a/crates/polars-core/src/chunked_array/builder/boolean.rs +++ b/crates/polars-core/src/chunked_array/builder/boolean.rs @@ -21,13 +21,14 @@ impl ChunkedBuilder for BooleanChunkedBuilder { fn finish(mut self) -> BooleanChunked { let arr = self.array_builder.as_box(); + let length = arr.len() as IdxSize; let mut ca = ChunkedArray { field: Arc::new(self.field), chunks: vec![arr], phantom: PhantomData, bit_settings: Default::default(), - length: 0, + length, null_count: 0, }; ca.compute_len(); diff --git a/crates/polars-lazy/src/physical_plan/planner/expr.rs b/crates/polars-lazy/src/physical_plan/planner/expr.rs index 0e614c4cb683..f690bf63f4e6 100644 --- a/crates/polars-lazy/src/physical_plan/planner/expr.rs +++ b/crates/polars-lazy/src/physical_plan/planner/expr.rs @@ -603,10 +603,11 @@ where let mut iter = chunks.into_iter(); let first = iter.next().unwrap(); - let out = iter.fold(first, |mut acc, s| { - acc.append(&s).unwrap(); + let dtype = first.dtype(); + let out = iter.fold(first.to_physical_repr().into_owned(), |mut acc, s| { + acc.append(&s.to_physical_repr()).unwrap(); acc }); - f(out).map(Some) + unsafe { f(out.cast_unchecked(&dtype).unwrap()).map(Some) } }