Skip to content

Commit a1ecb12

Browse files
authored
Fix date time parts scalar_at to cast (#1584)
1 parent d309778 commit a1ecb12

File tree

1 file changed

+10
-4
lines changed
  • encodings/datetime-parts/src/compute

1 file changed

+10
-4
lines changed

encodings/datetime-parts/src/compute/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use vortex_array::compute::{
88
use vortex_array::validity::ArrayValidity;
99
use vortex_array::{ArrayDType, ArrayData, IntoArrayData, IntoArrayVariant};
1010
use vortex_datetime_dtype::{TemporalMetadata, TimeUnit};
11-
use vortex_dtype::Nullability::NonNullable;
11+
use vortex_dtype::Nullability::{NonNullable, Nullable};
1212
use vortex_dtype::{DType, PType};
1313
use vortex_error::{vortex_bail, VortexExpect, VortexResult};
1414
use vortex_scalar::{PrimitiveScalar, Scalar};
@@ -76,9 +76,15 @@ impl ScalarAtFn<DateTimePartsArray> for DateTimePartsEncoding {
7676
TimeUnit::D => vortex_bail!("Invalid time unit D"),
7777
};
7878

79-
let days: i64 = scalar_at(array.days(), index)?.try_into()?;
80-
let seconds: i64 = scalar_at(array.seconds(), index)?.try_into()?;
81-
let subseconds: i64 = scalar_at(array.subsecond(), index)?.try_into()?;
79+
let days: i64 = scalar_at(array.days(), index)?
80+
.cast(&DType::Primitive(PType::I64, Nullable))?
81+
.try_into()?;
82+
let seconds: i64 = scalar_at(array.seconds(), index)?
83+
.cast(&DType::Primitive(PType::I64, NonNullable))?
84+
.try_into()?;
85+
let subseconds: i64 = scalar_at(array.subsecond(), index)?
86+
.cast(&DType::Primitive(PType::I64, NonNullable))?
87+
.try_into()?;
8288

8389
let scalar = days * 86_400 * divisor + seconds * divisor + subseconds;
8490

0 commit comments

Comments
 (0)