From 3b1079d0d6a27750784c7c2a0a4a5d64f8a78a5e Mon Sep 17 00:00:00 2001 From: Andrew Duffy Date: Wed, 23 Oct 2024 11:23:21 -0400 Subject: [PATCH] fix: canonicalize null ConstantArray to VarBinViewArray (#1122) previously we were using a null utf8 scalar, we should have been using a 0u8 scalar as that is the type of the views array. --- vortex-array/src/array/constant/canonical.rs | 6 +++--- vortex-array/src/array/varbinview/mod.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vortex-array/src/array/constant/canonical.rs b/vortex-array/src/array/constant/canonical.rs index a529f849ab..cc33f17156 100644 --- a/vortex-array/src/array/constant/canonical.rs +++ b/vortex-array/src/array/constant/canonical.rs @@ -3,11 +3,11 @@ use arrow_buffer::{BooleanBuffer, BufferBuilder}; use vortex_buffer::Buffer; use vortex_dtype::{match_each_native_ptype, DType, Nullability, PType}; use vortex_error::{vortex_bail, VortexResult}; -use vortex_scalar::{BinaryScalar, BoolScalar, Scalar, Utf8Scalar}; +use vortex_scalar::{BinaryScalar, BoolScalar, Utf8Scalar}; use crate::array::constant::ConstantArray; use crate::array::primitive::PrimitiveArray; -use crate::array::{BinaryView, BoolArray, VarBinViewArray}; +use crate::array::{BinaryView, BoolArray, VarBinViewArray, VIEW_SIZE_BYTES}; use crate::validity::Validity; use crate::{ArrayDType, Canonical, IntoArray, IntoCanonical}; @@ -70,7 +70,7 @@ fn canonical_byte_view( ) -> VortexResult { match scalar_bytes { None => { - let views = ConstantArray::new(Scalar::null(dtype.clone()), len); + let views = ConstantArray::new(0u8, len * VIEW_SIZE_BYTES); VarBinViewArray::try_new( views.into_array(), diff --git a/vortex-array/src/array/varbinview/mod.rs b/vortex-array/src/array/varbinview/mod.rs index bfa5aa8fc8..79e04d6c6d 100644 --- a/vortex-array/src/array/varbinview/mod.rs +++ b/vortex-array/src/array/varbinview/mod.rs @@ -227,12 +227,12 @@ impl VarBinViewArray { validity: Validity, ) -> VortexResult { if !matches!(views.dtype(), &DType::BYTES) { - vortex_bail!(MismatchedTypes: "u8", views.dtype()); + vortex_bail!(MismatchedTypes: "views u8", views.dtype()); } for d in buffers.iter() { if !matches!(d.dtype(), &DType::BYTES) { - vortex_bail!(MismatchedTypes: "u8", d.dtype()); + vortex_bail!(MismatchedTypes: "buffers u8", d.dtype()); } }