This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 365a9ecc40 [Variant] Add variant to arrow for
Date64/Timestamp(Second/Millisecond)/Time32/Time64 (#8950)
365a9ecc40 is described below
commit 365a9ecc400a99803cee0698b1214f25b0574be9
Author: Congxian Qiu <[email protected]>
AuthorDate: Fri Dec 12 03:32:07 2025 +0800
[Variant] Add variant to arrow for
Date64/Timestamp(Second/Millisecond)/Time32/Time64 (#8950)
# Which issue does this PR close?
- Closes #8805 .
# What changes are included in this PR?
Add support for variant to arrow primitive types(for the remaining arrow
primitive types), and some tests to cover them.
For the behavior that can't be cast safely, I'll continue to track them
in #8086 and #8873
> Self::make_time will return the native value for the given timestamp
type
> Date64Type::from_naive_date(v) will return the milliseconds elapsed
since UNIX epoch
| VariantType | Arrow Type | Logic|
| -- | -- | -- |
| Date | Date64 | datatypes::Date64Type::from_naive_date(v) |
| Timestamp\[_ntz\](Micro/Nano) | Timestamp\[_ntz\](Second) | - if
(timestamp.nano == 0) Self::make_time(timestamp) <br> - else None |
| Timestamp\[_ntz\](Micro/Nano) | Timestamp\[_ntz\](Millisecond) | - if
(timestamp.nano % 1_000_000 == 0) Self::make_time(timestamp) <br> - else
None |
| Time | Time32(Second)| - if (timestamp.nano == 0) v.
num_seconds_from_midnight() <br> - else None |
| Time | Time32(Millisecond) | - if (timestamp.nano % 1_000_000 == 0)
v.num_seconds_from_midnight() * 1000 + v.nano / 1_000_000 <br> - else
Nnoe |
| Time | Time64(Nano) | timestamp.num_seconds * 1_000_000_000 + v.nano |
# Are these changes tested?
Added some new tests
# Are there any user-facing changes?
No
---------
Co-authored-by: Andrew Lamb <[email protected]>
---
parquet-variant-compute/src/type_conversion.rs | 87 +++++++++-
parquet-variant-compute/src/variant_get.rs | 206 +++++++++++++++++++++++-
parquet-variant-compute/src/variant_to_arrow.rs | 96 ++++++++---
3 files changed, 357 insertions(+), 32 deletions(-)
diff --git a/parquet-variant-compute/src/type_conversion.rs
b/parquet-variant-compute/src/type_conversion.rs
index 0716469f76..0106517565 100644
--- a/parquet-variant-compute/src/type_conversion.rs
+++ b/parquet-variant-compute/src/type_conversion.rs
@@ -56,7 +56,7 @@ macro_rules! impl_primitive_from_variant {
impl PrimitiveFromVariant for $arrow_type {
fn from_variant(variant: &Variant<'_, '_>) -> Option<Self::Native>
{
let value = variant.$variant_method();
- $( let value = value.map($cast_fn); )?
+ $( let value = value.and_then($cast_fn); )?
value
}
}
@@ -84,14 +84,87 @@ impl_primitive_from_variant!(datatypes::UInt64Type, as_u64);
impl_primitive_from_variant!(datatypes::Float16Type, as_f16);
impl_primitive_from_variant!(datatypes::Float32Type, as_f32);
impl_primitive_from_variant!(datatypes::Float64Type, as_f64);
-impl_primitive_from_variant!(
- datatypes::Date32Type,
- as_naive_date,
- datatypes::Date32Type::from_naive_date
-);
+impl_primitive_from_variant!(datatypes::Date32Type, as_naive_date, |v| {
+ Some(datatypes::Date32Type::from_naive_date(v))
+});
+impl_primitive_from_variant!(datatypes::Date64Type, as_naive_date, |v| {
+ Some(datatypes::Date64Type::from_naive_date(v))
+});
+impl_primitive_from_variant!(datatypes::Time32SecondType, as_time_utc, |v| {
+ // Return None if there are leftover nanoseconds
+ if v.nanosecond() != 0 {
+ None
+ } else {
+ Some(v.num_seconds_from_midnight() as i32)
+ }
+});
+impl_primitive_from_variant!(datatypes::Time32MillisecondType, as_time_utc,
|v| {
+ // Return None if there are leftover microseconds
+ if v.nanosecond() % 1_000_000 != 0 {
+ None
+ } else {
+ Some((v.num_seconds_from_midnight() * 1_000) as i32 + (v.nanosecond()
/ 1_000_000) as i32)
+ }
+});
impl_primitive_from_variant!(datatypes::Time64MicrosecondType, as_time_utc,
|v| {
- (v.num_seconds_from_midnight() * 1_000_000 + v.nanosecond() / 1_000) as i64
+ Some((v.num_seconds_from_midnight() * 1_000_000 + v.nanosecond() / 1_000)
as i64)
});
+impl_primitive_from_variant!(datatypes::Time64NanosecondType, as_time_utc, |v|
{
+ // convert micro to nano seconds
+ Some(v.num_seconds_from_midnight() as i64 * 1_000_000_000 + v.nanosecond()
as i64)
+});
+impl_timestamp_from_variant!(
+ datatypes::TimestampSecondType,
+ as_timestamp_ntz_nanos,
+ ntz = true,
+ |timestamp| {
+ // Return None if there are leftover nanoseconds
+ if timestamp.nanosecond() != 0 {
+ None
+ } else {
+ Self::make_value(timestamp)
+ }
+ }
+);
+impl_timestamp_from_variant!(
+ datatypes::TimestampSecondType,
+ as_timestamp_nanos,
+ ntz = false,
+ |timestamp| {
+ // Return None if there are leftover nanoseconds
+ if timestamp.nanosecond() != 0 {
+ None
+ } else {
+ Self::make_value(timestamp.naive_utc())
+ }
+ }
+);
+impl_timestamp_from_variant!(
+ datatypes::TimestampMillisecondType,
+ as_timestamp_ntz_nanos,
+ ntz = true,
+ |timestamp| {
+ // Return None if there are leftover microseconds
+ if timestamp.nanosecond() % 1_000_000 != 0 {
+ None
+ } else {
+ Self::make_value(timestamp)
+ }
+ }
+);
+impl_timestamp_from_variant!(
+ datatypes::TimestampMillisecondType,
+ as_timestamp_nanos,
+ ntz = false,
+ |timestamp| {
+ // Return None if there are leftover microseconds
+ if timestamp.nanosecond() % 1_000_000 != 0 {
+ None
+ } else {
+ Self::make_value(timestamp.naive_utc())
+ }
+ }
+);
impl_timestamp_from_variant!(
datatypes::TimestampMicrosecondType,
as_timestamp_ntz_micros,
diff --git a/parquet-variant-compute/src/variant_get.rs
b/parquet-variant-compute/src/variant_get.rs
index 1c5ba16ae9..624c8ae128 100644
--- a/parquet-variant-compute/src/variant_get.rs
+++ b/parquet-variant-compute/src/variant_get.rs
@@ -337,10 +337,10 @@ mod test {
use crate::{VariantArray, VariantArrayBuilder, json_to_variant};
use arrow::array::{
Array, ArrayRef, AsArray, BinaryArray, BinaryViewArray, BooleanArray,
Date32Array,
- Decimal32Array, Decimal64Array, Decimal128Array, Decimal256Array,
Float32Array,
- Float64Array, Int8Array, Int16Array, Int32Array, Int64Array,
LargeBinaryArray,
- LargeStringArray, NullBuilder, StringArray, StringViewArray,
StructArray,
- Time64MicrosecondArray,
+ Date64Array, Decimal32Array, Decimal64Array, Decimal128Array,
Decimal256Array,
+ Float32Array, Float64Array, Int8Array, Int16Array, Int32Array,
Int64Array,
+ LargeBinaryArray, LargeStringArray, NullBuilder, StringArray,
StringViewArray, StructArray,
+ Time32MillisecondArray, Time32SecondArray, Time64MicrosecondArray,
Time64NanosecondArray,
};
use arrow::buffer::NullBuffer;
use arrow::compute::CastOptions;
@@ -1000,6 +1000,152 @@ mod test {
}
);
+ perfectly_shredded_variant_array_fn!(
+
perfectly_shredded_timestamp_micro_variant_array_for_second_and_milli_second,
+ || {
+ arrow::array::TimestampMicrosecondArray::from(vec![
+ Some(1234), // can't be cast to second & millisecond
+ Some(1234000), // can be cast to millisecond, but not second
+ Some(1234000000), // can be cast to second & millisecond
+ ])
+ .with_timezone("+00:00")
+ }
+ );
+
+ // The following two tests wants to cover the micro with timezone ->
milli/second cases
+ // there are three test items, which contains some items can be cast
safely, and some can't
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_timestamp_micro_as_timestamp_second,
+ DataType::Timestamp(TimeUnit::Second, Some(Arc::from("+00:00"))),
+
perfectly_shredded_timestamp_micro_variant_array_for_second_and_milli_second,
+ arrow::array::TimestampSecondArray::from(vec![
+ None,
+ None, // Return None if can't be cast to second safely
+ Some(1234)
+ ])
+ .with_timezone("+00:00")
+ );
+
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_timestamp_micro_as_timestamp_milli,
+ DataType::Timestamp(TimeUnit::Millisecond, Some(Arc::from("+00:00"))),
+
perfectly_shredded_timestamp_micro_variant_array_for_second_and_milli_second,
+ arrow::array::TimestampMillisecondArray::from(vec![
+ None, // Return None if can't be cast to millisecond safely
+ Some(1234),
+ Some(1234000)
+ ])
+ .with_timezone("+00:00")
+ );
+
+ perfectly_shredded_variant_array_fn!(
+
perfectly_shredded_timestamp_micro_ntz_variant_array_for_second_and_milli_second,
+ || {
+ arrow::array::TimestampMicrosecondArray::from(vec![
+ Some(1234), // can't be cast to second & millisecond
+ Some(1234000), // can be cast to millisecond, but not second
+ Some(1234000000), // can be cast to second & millisecond
+ ])
+ }
+ );
+
+ // The following two tests wants to cover the micro_ntz -> milli/second
cases
+ // there are three test items, which contains some items can be cast
safely, and some can't
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_timestamp_micro_ntz_as_timestamp_second,
+ DataType::Timestamp(TimeUnit::Second, None),
+
perfectly_shredded_timestamp_micro_ntz_variant_array_for_second_and_milli_second,
+ arrow::array::TimestampSecondArray::from(vec![
+ None,
+ None, // Return None if can't be cast to second safely
+ Some(1234)
+ ])
+ );
+
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_timestamp_micro_ntz_as_timestamp_milli,
+ DataType::Timestamp(TimeUnit::Millisecond, None),
+
perfectly_shredded_timestamp_micro_ntz_variant_array_for_second_and_milli_second,
+ arrow::array::TimestampMillisecondArray::from(vec![
+ None, // Return None if can't be cast to millisecond safely
+ Some(1234),
+ Some(1234000)
+ ])
+ );
+
+ perfectly_shredded_variant_array_fn!(
+
perfectly_shredded_timestamp_nano_variant_array_for_second_and_milli_second,
+ || {
+ arrow::array::TimestampNanosecondArray::from(vec![
+ Some(1234000), // can't be cast to second & millisecond
+ Some(1234000000), // can be cast to millisecond, but not
second
+ Some(1234000000000), // can be cast to second & millisecond
+ ])
+ .with_timezone("+00:00")
+ }
+ );
+
+ // The following two tests wants to cover the nano with timezone ->
milli/second cases
+ // there are three test items, which contains some items can be cast
safely, and some can't
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_timestamp_nano_as_timestamp_second,
+ DataType::Timestamp(TimeUnit::Second, Some(Arc::from("+00:00"))),
+
perfectly_shredded_timestamp_nano_variant_array_for_second_and_milli_second,
+ arrow::array::TimestampSecondArray::from(vec![
+ None,
+ None, // Return None if can't be cast to second safely
+ Some(1234)
+ ])
+ .with_timezone("+00:00")
+ );
+
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_timestamp_nano_as_timestamp_milli,
+ DataType::Timestamp(TimeUnit::Millisecond, Some(Arc::from("+00:00"))),
+
perfectly_shredded_timestamp_nano_variant_array_for_second_and_milli_second,
+ arrow::array::TimestampMillisecondArray::from(vec![
+ None, // Return None if can't be cast to millisecond safely
+ Some(1234),
+ Some(1234000)
+ ])
+ .with_timezone("+00:00")
+ );
+
+ perfectly_shredded_variant_array_fn!(
+
perfectly_shredded_timestamp_nano_ntz_variant_array_for_second_and_milli_second,
+ || {
+ arrow::array::TimestampNanosecondArray::from(vec![
+ Some(1234000), // can't be cast to second & millisecond
+ Some(1234000000), // can be cast to millisecond, but not
second
+ Some(1234000000000), // can be cast to second & millisecond
+ ])
+ }
+ );
+
+ // The following two tests wants to cover the nano_ntz -> milli/second
cases
+ // there are three test items, which contains some items can be cast
safely, and some can't
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_timestamp_nano_ntz_as_timestamp_second,
+ DataType::Timestamp(TimeUnit::Second, None),
+
perfectly_shredded_timestamp_nano_ntz_variant_array_for_second_and_milli_second,
+ arrow::array::TimestampSecondArray::from(vec![
+ None,
+ None, // Return None if can't be cast to second safely
+ Some(1234)
+ ])
+ );
+
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_timestamp_nano_ntz_as_timestamp_milli,
+ DataType::Timestamp(TimeUnit::Millisecond, None),
+
perfectly_shredded_timestamp_nano_ntz_variant_array_for_second_and_milli_second,
+ arrow::array::TimestampMillisecondArray::from(vec![
+ None, // Return None if can't be cast to millisecond safely
+ Some(1234),
+ Some(1234000)
+ ])
+ );
+
perfectly_shredded_to_arrow_primitive_test!(
get_variant_perfectly_shredded_timestamp_nano_ntz_as_timestamp_nano_ntz,
DataType::Timestamp(TimeUnit::Nanosecond, None),
@@ -1043,6 +1189,17 @@ mod test {
Date32Array::from(vec![Some(-12345), Some(17586), Some(20000)])
);
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_date_as_date64,
+ DataType::Date64,
+ perfectly_shredded_date_variant_array,
+ Date64Array::from(vec![
+ Some(-1066608000000),
+ Some(1519430400000),
+ Some(1728000000000)
+ ])
+ );
+
perfectly_shredded_variant_array_fn!(perfectly_shredded_time_variant_array, || {
Time64MicrosecondArray::from(vec![Some(12345000), Some(87654000),
Some(135792000)])
});
@@ -1054,6 +1211,47 @@ mod test {
Time64MicrosecondArray::from(vec![Some(12345000), Some(87654000),
Some(135792000)])
);
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_time_as_time64_nano,
+ DataType::Time64(TimeUnit::Nanosecond),
+ perfectly_shredded_time_variant_array,
+ Time64NanosecondArray::from(vec![
+ Some(12345000000),
+ Some(87654000000),
+ Some(135792000000)
+ ])
+ );
+
+
perfectly_shredded_variant_array_fn!(perfectly_shredded_time_variant_array_for_time32,
|| {
+ Time64MicrosecondArray::from(vec![
+ Some(1234), // This can't be cast to Time32 losslessly
+ Some(7654000), // This can be cast to Time32(Millisecond), but
not Time32(Second)
+ Some(35792000000), // This can be cast to Time32(Second) &
Time32(Millisecond)
+ ])
+ });
+
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_time_as_time32_second,
+ DataType::Time32(TimeUnit::Second),
+ perfectly_shredded_time_variant_array_for_time32,
+ Time32SecondArray::from(vec![
+ None,
+ None, // Return None if can't be cast to Time32(Second) safely
+ Some(35792)
+ ])
+ );
+
+ perfectly_shredded_to_arrow_primitive_test!(
+ get_variant_perfectly_shredded_time_as_time32_milli,
+ DataType::Time32(TimeUnit::Millisecond),
+ perfectly_shredded_time_variant_array_for_time32,
+ Time32MillisecondArray::from(vec![
+ None, // Return None if can't be cast to Time32(Second) safely
+ Some(7654),
+ Some(35792000)
+ ])
+ );
+
perfectly_shredded_variant_array_fn!(perfectly_shredded_null_variant_array, || {
let mut builder = NullBuilder::new();
builder.append_nulls(3);
diff --git a/parquet-variant-compute/src/variant_to_arrow.rs
b/parquet-variant-compute/src/variant_to_arrow.rs
index 9d158dd96d..7d4c427fa4 100644
--- a/parquet-variant-compute/src/variant_to_arrow.rs
+++ b/parquet-variant-compute/src/variant_to_arrow.rs
@@ -54,14 +54,24 @@ pub(crate) enum PrimitiveVariantToArrowRowBuilder<'a> {
Decimal64(VariantToDecimalArrowRowBuilder<'a, datatypes::Decimal64Type>),
Decimal128(VariantToDecimalArrowRowBuilder<'a, datatypes::Decimal128Type>),
Decimal256(VariantToDecimalArrowRowBuilder<'a, datatypes::Decimal256Type>),
+ TimestampSecond(VariantToTimestampArrowRowBuilder<'a,
datatypes::TimestampSecondType>),
+ TimestampSecondNtz(VariantToTimestampNtzArrowRowBuilder<'a,
datatypes::TimestampSecondType>),
+ TimestampMilli(VariantToTimestampArrowRowBuilder<'a,
datatypes::TimestampMillisecondType>),
+ TimestampMilliNtz(
+ VariantToTimestampNtzArrowRowBuilder<'a,
datatypes::TimestampMillisecondType>,
+ ),
TimestampMicro(VariantToTimestampArrowRowBuilder<'a,
datatypes::TimestampMicrosecondType>),
TimestampMicroNtz(
VariantToTimestampNtzArrowRowBuilder<'a,
datatypes::TimestampMicrosecondType>,
),
TimestampNano(VariantToTimestampArrowRowBuilder<'a,
datatypes::TimestampNanosecondType>),
TimestampNanoNtz(VariantToTimestampNtzArrowRowBuilder<'a,
datatypes::TimestampNanosecondType>),
- Time(VariantToPrimitiveArrowRowBuilder<'a,
datatypes::Time64MicrosecondType>),
- Date(VariantToPrimitiveArrowRowBuilder<'a, datatypes::Date32Type>),
+ Time32Second(VariantToPrimitiveArrowRowBuilder<'a,
datatypes::Time32SecondType>),
+ Time32Milli(VariantToPrimitiveArrowRowBuilder<'a,
datatypes::Time32MillisecondType>),
+ Time64Micro(VariantToPrimitiveArrowRowBuilder<'a,
datatypes::Time64MicrosecondType>),
+ Time64Nano(VariantToPrimitiveArrowRowBuilder<'a,
datatypes::Time64NanosecondType>),
+ Date32(VariantToPrimitiveArrowRowBuilder<'a, datatypes::Date32Type>),
+ Date64(VariantToPrimitiveArrowRowBuilder<'a, datatypes::Date64Type>),
Uuid(VariantToUuidArrowRowBuilder<'a>),
String(VariantToStringArrowBuilder<'a, StringBuilder>),
LargeString(VariantToStringArrowBuilder<'a, LargeStringBuilder>),
@@ -104,12 +114,20 @@ impl<'a> PrimitiveVariantToArrowRowBuilder<'a> {
Decimal64(b) => b.append_null(),
Decimal128(b) => b.append_null(),
Decimal256(b) => b.append_null(),
+ TimestampSecond(b) => b.append_null(),
+ TimestampSecondNtz(b) => b.append_null(),
+ TimestampMilli(b) => b.append_null(),
+ TimestampMilliNtz(b) => b.append_null(),
TimestampMicro(b) => b.append_null(),
TimestampMicroNtz(b) => b.append_null(),
TimestampNano(b) => b.append_null(),
TimestampNanoNtz(b) => b.append_null(),
- Time(b) => b.append_null(),
- Date(b) => b.append_null(),
+ Time32Second(b) => b.append_null(),
+ Time32Milli(b) => b.append_null(),
+ Time64Micro(b) => b.append_null(),
+ Time64Nano(b) => b.append_null(),
+ Date32(b) => b.append_null(),
+ Date64(b) => b.append_null(),
Uuid(b) => b.append_null(),
String(b) => b.append_null(),
LargeString(b) => b.append_null(),
@@ -140,12 +158,20 @@ impl<'a> PrimitiveVariantToArrowRowBuilder<'a> {
Decimal64(b) => b.append_value(value),
Decimal128(b) => b.append_value(value),
Decimal256(b) => b.append_value(value),
+ TimestampSecond(b) => b.append_value(value),
+ TimestampSecondNtz(b) => b.append_value(value),
+ TimestampMilli(b) => b.append_value(value),
+ TimestampMilliNtz(b) => b.append_value(value),
TimestampMicro(b) => b.append_value(value),
TimestampMicroNtz(b) => b.append_value(value),
TimestampNano(b) => b.append_value(value),
TimestampNanoNtz(b) => b.append_value(value),
- Time(b) => b.append_value(value),
- Date(b) => b.append_value(value),
+ Time32Second(b) => b.append_value(value),
+ Time32Milli(b) => b.append_value(value),
+ Time64Micro(b) => b.append_value(value),
+ Time64Nano(b) => b.append_value(value),
+ Date32(b) => b.append_value(value),
+ Date64(b) => b.append_value(value),
Uuid(b) => b.append_value(value),
String(b) => b.append_value(value),
LargeString(b) => b.append_value(value),
@@ -176,12 +202,20 @@ impl<'a> PrimitiveVariantToArrowRowBuilder<'a> {
Decimal64(b) => b.finish(),
Decimal128(b) => b.finish(),
Decimal256(b) => b.finish(),
+ TimestampSecond(b) => b.finish(),
+ TimestampSecondNtz(b) => b.finish(),
+ TimestampMilli(b) => b.finish(),
+ TimestampMilliNtz(b) => b.finish(),
TimestampMicro(b) => b.finish(),
TimestampMicroNtz(b) => b.finish(),
TimestampNano(b) => b.finish(),
TimestampNanoNtz(b) => b.finish(),
- Time(b) => b.finish(),
- Date(b) => b.finish(),
+ Time32Second(b) => b.finish(),
+ Time32Milli(b) => b.finish(),
+ Time64Micro(b) => b.finish(),
+ Time64Nano(b) => b.finish(),
+ Date32(b) => b.finish(),
+ Date64(b) => b.finish(),
Uuid(b) => b.finish(),
String(b) => b.finish(),
LargeString(b) => b.finish(),
@@ -292,23 +326,48 @@ pub(crate) fn
make_primitive_variant_to_arrow_row_builder<'a>(
DataType::Decimal256(precision, scale) => Decimal256(
VariantToDecimalArrowRowBuilder::new(cast_options, capacity,
*precision, *scale)?,
),
- DataType::Date32 => Date(VariantToPrimitiveArrowRowBuilder::new(
+ DataType::Date32 => Date32(VariantToPrimitiveArrowRowBuilder::new(
cast_options,
capacity,
)),
- DataType::Date64 | DataType::Time32(_) => {
- return Err(ArrowError::NotYetImplemented(format!(
- "DataType {data_type:?} not yet implemented"
+ DataType::Date64 => Date64(VariantToPrimitiveArrowRowBuilder::new(
+ cast_options,
+ capacity,
+ )),
+ DataType::Time32(TimeUnit::Second) => Time32Second(
+ VariantToPrimitiveArrowRowBuilder::new(cast_options, capacity),
+ ),
+ DataType::Time32(TimeUnit::Millisecond) => Time32Milli(
+ VariantToPrimitiveArrowRowBuilder::new(cast_options, capacity),
+ ),
+ DataType::Time32(t) => {
+ return Err(ArrowError::InvalidArgumentError(format!(
+ "The unit for Time32 must be second/millisecond, received
{t:?}"
)));
}
- DataType::Time64(TimeUnit::Microsecond) => Time(
+ DataType::Time64(TimeUnit::Microsecond) => Time64Micro(
VariantToPrimitiveArrowRowBuilder::new(cast_options, capacity),
),
- DataType::Time64(_) => {
- return Err(ArrowError::NotYetImplemented(format!(
- "DataType {data_type:?} not yet implemented"
+ DataType::Time64(TimeUnit::Nanosecond) => Time64Nano(
+ VariantToPrimitiveArrowRowBuilder::new(cast_options, capacity),
+ ),
+ DataType::Time64(t) => {
+ return Err(ArrowError::InvalidArgumentError(format!(
+ "The unit for Time64 must be micro/nano seconds, received
{t:?}"
)));
}
+ DataType::Timestamp(TimeUnit::Second, None) => TimestampSecondNtz(
+ VariantToTimestampNtzArrowRowBuilder::new(cast_options,
capacity),
+ ),
+ DataType::Timestamp(TimeUnit::Second, tz) => TimestampSecond(
+ VariantToTimestampArrowRowBuilder::new(cast_options, capacity,
tz.clone()),
+ ),
+ DataType::Timestamp(TimeUnit::Millisecond, None) =>
TimestampMilliNtz(
+ VariantToTimestampNtzArrowRowBuilder::new(cast_options,
capacity),
+ ),
+ DataType::Timestamp(TimeUnit::Millisecond, tz) => TimestampMilli(
+ VariantToTimestampArrowRowBuilder::new(cast_options, capacity,
tz.clone()),
+ ),
DataType::Timestamp(TimeUnit::Microsecond, None) =>
TimestampMicroNtz(
VariantToTimestampNtzArrowRowBuilder::new(cast_options,
capacity),
),
@@ -321,11 +380,6 @@ pub(crate) fn
make_primitive_variant_to_arrow_row_builder<'a>(
DataType::Timestamp(TimeUnit::Nanosecond, tz) => TimestampNano(
VariantToTimestampArrowRowBuilder::new(cast_options, capacity,
tz.clone()),
),
- DataType::Timestamp(..) => {
- return Err(ArrowError::NotYetImplemented(format!(
- "DataType {data_type:?} not yet implemented"
- )));
- }
DataType::Duration(_) | DataType::Interval(_) => {
return Err(ArrowError::InvalidArgumentError(
"Casting Variant to duration/interval types is not
supported. \