Skip to content

Commit bae2e8e

Browse files
authored
Explicitly handle null scalar value canonicalizing ConstantArray (#2092)
This was a code path that initially masked issues with converting scalars that #2091 fixed
1 parent a40f50a commit bae2e8e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

vortex-array/src/array/constant/canonical.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use arrow_array::builder::make_view;
22
use arrow_buffer::BooleanBuffer;
33
use vortex_buffer::{buffer, Buffer, BufferMut};
44
use vortex_dtype::{match_each_native_ptype, DType, Nullability};
5-
use vortex_error::{vortex_bail, VortexResult};
5+
use vortex_error::{vortex_bail, VortexExpect, VortexResult};
66
use vortex_scalar::{BinaryScalar, BoolScalar, ExtScalar, Utf8Scalar};
77

88
use crate::array::constant::ConstantArray;
@@ -36,7 +36,15 @@ impl IntoCanonical for ConstantArray {
3636
DType::Primitive(ptype, ..) => {
3737
match_each_native_ptype!(ptype, |$P| {
3838
Canonical::Primitive(PrimitiveArray::new(
39-
Buffer::full($P::try_from(scalar).unwrap_or_else(|_| $P::default()), self.len()),
39+
if scalar.is_valid() {
40+
Buffer::full(
41+
$P::try_from(scalar)
42+
.vortex_expect("Couldn't unwrap scalar to primitive"),
43+
self.len(),
44+
)
45+
} else {
46+
Buffer::zeroed(self.len())
47+
},
4048
validity,
4149
))
4250
})

0 commit comments

Comments
 (0)