From 8d4f5f216afba9969fb43012ce51e8796326f910 Mon Sep 17 00:00:00 2001 From: Will Manning Date: Thu, 3 Oct 2024 17:04:50 +0100 Subject: [PATCH] fix: cast error in compress_noci benchmark (#971) --- encodings/datetime-parts/src/compress.rs | 9 +++++---- vortex-array/src/canonical.rs | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/encodings/datetime-parts/src/compress.rs b/encodings/datetime-parts/src/compress.rs index e40b893c8c..5c38850a5d 100644 --- a/encodings/datetime-parts/src/compress.rs +++ b/encodings/datetime-parts/src/compress.rs @@ -1,8 +1,8 @@ use vortex::array::{PrimitiveArray, TemporalArray}; use vortex::compute::unary::try_cast; -use vortex::{Array, IntoArray, IntoArrayVariant}; +use vortex::{Array, ArrayDType as _, IntoArray, IntoArrayVariant}; use vortex_datetime_dtype::TimeUnit; -use vortex_dtype::PType; +use vortex_dtype::{DType, PType}; use vortex_error::{vortex_bail, VortexResult}; /// Compress a `TemporalArray` into day, second, and subsecond components. @@ -11,9 +11,10 @@ use vortex_error::{vortex_bail, VortexResult}; /// cascading compression. pub fn compress_temporal(array: TemporalArray) -> VortexResult<(Array, Array, Array)> { // After this operation, timestamps will be PrimitiveArray + let timestamps = array.temporal_values().into_primitive()?; let timestamps = try_cast( - array.temporal_values().into_primitive()?.into_array(), - PType::I64.into(), + ×tamps, + &DType::Primitive(PType::I64, timestamps.dtype().nullability()), )?; let divisor = match array.temporal_metadata().time_unit() { TimeUnit::Ns => 1_000_000_000, diff --git a/vortex-array/src/canonical.rs b/vortex-array/src/canonical.rs index bc486bed48..e890d28496 100644 --- a/vortex-array/src/canonical.rs +++ b/vortex-array/src/canonical.rs @@ -286,8 +286,11 @@ fn varbin_to_arrow(varbin_array: VarBinArray) -> VortexResult { fn temporal_to_arrow(temporal_array: TemporalArray) -> VortexResult { macro_rules! extract_temporal_values { ($values:expr, $prim:ty) => {{ - let temporal_values = - try_cast($values, <$prim as NativePType>::PTYPE.into())?.into_primitive()?; + let temporal_values = try_cast( + $values, + &DType::Primitive(<$prim as NativePType>::PTYPE, $values.dtype().nullability()), + )? + .into_primitive()?; let len = temporal_values.len(); let nulls = temporal_values.logical_validity().to_null_buffer()?; let scalars =