@@ -301,14 +301,14 @@ mod test {
301301 use crate :: variant_array:: { ShreddedVariantFieldArray , StructArrayBuilder } ;
302302 use crate :: VariantArray ;
303303 use arrow:: array:: {
304- Array , ArrayRef , AsArray , BinaryViewArray , Date32Array , Float32Array , Float64Array ,
305- Int16Array , Int32Array , Int64Array , Int8Array , StringArray , StructArray ,
304+ Array , ArrayRef , AsArray , BinaryViewArray , BooleanArray , Date32Array , Float32Array ,
305+ Float64Array , Int16Array , Int32Array , Int64Array , Int8Array , StringArray , StructArray ,
306306 } ;
307307 use arrow:: buffer:: NullBuffer ;
308308 use arrow:: compute:: CastOptions ;
309309 use arrow:: datatypes:: DataType :: { Int16 , Int32 , Int64 } ;
310310 use arrow_schema:: DataType :: { Boolean , Float32 , Float64 , Int8 } ;
311- use arrow_schema:: { DataType , Field , FieldRef , Fields } ;
311+ use arrow_schema:: { DataType , Field , FieldRef , Fields , TimeUnit } ;
312312 use chrono:: DateTime ;
313313 use parquet_variant:: { Variant , VariantPath , EMPTY_VARIANT_METADATA_BYTES } ;
314314
@@ -699,7 +699,7 @@ mod test {
699699 }
700700
701701 macro_rules! perfectly_shredded_to_arrow_primitive_test {
702- ( $name: ident, $primitive_type: ident , $perfectly_shredded_array_gen_fun: ident, $expected_array: expr) => {
702+ ( $name: ident, $primitive_type: expr , $perfectly_shredded_array_gen_fun: ident, $expected_array: expr) => {
703703 #[ test]
704704 fn $name( ) {
705705 let array = $perfectly_shredded_array_gen_fun( ) ;
@@ -842,6 +842,103 @@ mod test {
842842 f64
843843 ) ;
844844
845+ perfectly_shredded_variant_array_fn ! (
846+ perfectly_shredded_timestamp_micro_ntz_variant_array,
847+ || {
848+ arrow:: array:: TimestampMicrosecondArray :: from( vec![
849+ Some ( -456000 ) ,
850+ Some ( 1758602096000001 ) ,
851+ Some ( 1758602096000002 ) ,
852+ ] )
853+ }
854+ ) ;
855+
856+ perfectly_shredded_to_arrow_primitive_test ! (
857+ get_variant_perfectly_shredded_timestamp_micro_ntz_as_timestamp_micro_ntz,
858+ DataType :: Timestamp ( TimeUnit :: Microsecond , None ) ,
859+ perfectly_shredded_timestamp_micro_ntz_variant_array,
860+ arrow:: array:: TimestampMicrosecondArray :: from( vec![
861+ Some ( -456000 ) ,
862+ Some ( 1758602096000001 ) ,
863+ Some ( 1758602096000002 ) ,
864+ ] )
865+ ) ;
866+
867+ perfectly_shredded_variant_array_fn ! ( perfectly_shredded_timestamp_micro_variant_array, || {
868+ arrow:: array:: TimestampMicrosecondArray :: from( vec![
869+ Some ( -456000 ) ,
870+ Some ( 1758602096000001 ) ,
871+ Some ( 1758602096000002 ) ,
872+ ] )
873+ . with_timezone( "+00:00" )
874+ } ) ;
875+
876+ perfectly_shredded_to_arrow_primitive_test ! (
877+ get_variant_perfectly_shredded_timestamp_micro_as_timestamp_micro,
878+ DataType :: Timestamp ( TimeUnit :: Microsecond , Some ( Arc :: from( "+00:00" ) ) ) ,
879+ perfectly_shredded_timestamp_micro_variant_array,
880+ arrow:: array:: TimestampMicrosecondArray :: from( vec![
881+ Some ( -456000 ) ,
882+ Some ( 1758602096000001 ) ,
883+ Some ( 1758602096000002 ) ,
884+ ] )
885+ . with_timezone( "+00:00" )
886+ ) ;
887+
888+ perfectly_shredded_variant_array_fn ! (
889+ perfectly_shredded_timestamp_nano_ntz_variant_array,
890+ || {
891+ arrow:: array:: TimestampNanosecondArray :: from( vec![
892+ Some ( -4999999561 ) ,
893+ Some ( 1758602096000000001 ) ,
894+ Some ( 1758602096000000002 ) ,
895+ ] )
896+ }
897+ ) ;
898+
899+ perfectly_shredded_to_arrow_primitive_test ! (
900+ get_variant_perfectly_shredded_timestamp_nano_ntz_as_timestamp_nano_ntz,
901+ DataType :: Timestamp ( TimeUnit :: Nanosecond , None ) ,
902+ perfectly_shredded_timestamp_nano_ntz_variant_array,
903+ arrow:: array:: TimestampNanosecondArray :: from( vec![
904+ Some ( -4999999561 ) ,
905+ Some ( 1758602096000000001 ) ,
906+ Some ( 1758602096000000002 ) ,
907+ ] )
908+ ) ;
909+
910+ perfectly_shredded_variant_array_fn ! ( perfectly_shredded_timestamp_nano_variant_array, || {
911+ arrow:: array:: TimestampNanosecondArray :: from( vec![
912+ Some ( -4999999561 ) ,
913+ Some ( 1758602096000000001 ) ,
914+ Some ( 1758602096000000002 ) ,
915+ ] )
916+ . with_timezone( "+00:00" )
917+ } ) ;
918+
919+ perfectly_shredded_to_arrow_primitive_test ! (
920+ get_variant_perfectly_shredded_timestamp_nano_as_timestamp_nano,
921+ DataType :: Timestamp ( TimeUnit :: Nanosecond , Some ( Arc :: from( "+00:00" ) ) ) ,
922+ perfectly_shredded_timestamp_nano_variant_array,
923+ arrow:: array:: TimestampNanosecondArray :: from( vec![
924+ Some ( -4999999561 ) ,
925+ Some ( 1758602096000000001 ) ,
926+ Some ( 1758602096000000002 ) ,
927+ ] )
928+ . with_timezone( "+00:00" )
929+ ) ;
930+
931+ perfectly_shredded_variant_array_fn ! ( perfectly_shredded_date_variant_array, || {
932+ Date32Array :: from( vec![ Some ( -12345 ) , Some ( 17586 ) , Some ( 20000 ) ] )
933+ } ) ;
934+
935+ perfectly_shredded_to_arrow_primitive_test ! (
936+ get_variant_perfectly_shredded_date_as_date,
937+ DataType :: Date32 ,
938+ perfectly_shredded_date_variant_array,
939+ Date32Array :: from( vec![ Some ( -12345 ) , Some ( 17586 ) , Some ( 20000 ) ] )
940+ ) ;
941+
845942 macro_rules! assert_variant_get_as_variant_array_with_default_option {
846943 ( $variant_array: expr, $array_expected: expr) => { {
847944 let options = GetOptions :: new( ) ;
0 commit comments