@@ -297,18 +297,19 @@ mod test {
297297 use std:: sync:: Arc ;
298298
299299 use super :: { variant_get, GetOptions } ;
300+ use crate :: arrow_to_variant:: ArrowToVariantRowBuilder :: Date32 ;
300301 use crate :: json_to_variant;
301302 use crate :: variant_array:: { ShreddedVariantFieldArray , StructArrayBuilder } ;
302303 use crate :: VariantArray ;
303304 use arrow:: array:: {
304- Array , ArrayRef , AsArray , BinaryViewArray , Date32Array , Float32Array , Float64Array ,
305- Int16Array , Int32Array , Int64Array , Int8Array , StringArray , StructArray ,
305+ Array , ArrayRef , AsArray , BinaryViewArray , BooleanArray , Date32Array , Float32Array ,
306+ Float64Array , Int16Array , Int32Array , Int64Array , Int8Array , StringArray , StructArray ,
306307 } ;
307308 use arrow:: buffer:: NullBuffer ;
308309 use arrow:: compute:: CastOptions ;
309310 use arrow:: datatypes:: DataType :: { Int16 , Int32 , Int64 } ;
310311 use arrow_schema:: DataType :: { Boolean , Float32 , Float64 , Int8 } ;
311- use arrow_schema:: { DataType , Field , FieldRef , Fields } ;
312+ use arrow_schema:: { DataType , Field , FieldRef , Fields , TimeUnit } ;
312313 use chrono:: DateTime ;
313314 use parquet_variant:: { Variant , VariantPath , EMPTY_VARIANT_METADATA_BYTES } ;
314315
@@ -699,7 +700,7 @@ mod test {
699700 }
700701
701702 macro_rules! perfectly_shredded_to_arrow_primitive_test {
702- ( $name: ident, $primitive_type: ident , $perfectly_shredded_array_gen_fun: ident, $expected_array: expr) => {
703+ ( $name: ident, $primitive_type: expr , $perfectly_shredded_array_gen_fun: ident, $expected_array: expr) => {
703704 #[ test]
704705 fn $name( ) {
705706 let array = $perfectly_shredded_array_gen_fun( ) ;
@@ -842,6 +843,103 @@ mod test {
842843 f64
843844 ) ;
844845
846+ perfectly_shredded_variant_array_fn ! (
847+ perfectly_shredded_timestamp_micro_ntz_variant_array,
848+ || {
849+ arrow:: array:: TimestampMicrosecondArray :: from( vec![
850+ Some ( -456000 ) ,
851+ Some ( 1758602096000001 ) ,
852+ Some ( 1758602096000002 ) ,
853+ ] )
854+ }
855+ ) ;
856+
857+ perfectly_shredded_to_arrow_primitive_test ! (
858+ get_variant_perfectly_shredded_timestamp_micro_ntz_as_timestamp_micro_ntz,
859+ DataType :: Timestamp ( TimeUnit :: Microsecond , None ) ,
860+ perfectly_shredded_timestamp_micro_ntz_variant_array,
861+ arrow:: array:: TimestampMicrosecondArray :: from( vec![
862+ Some ( -456000 ) ,
863+ Some ( 1758602096000001 ) ,
864+ Some ( 1758602096000002 ) ,
865+ ] )
866+ ) ;
867+
868+ perfectly_shredded_variant_array_fn ! ( perfectly_shredded_timestamp_micro_variant_array, || {
869+ arrow:: array:: TimestampMicrosecondArray :: from( vec![
870+ Some ( -456000 ) ,
871+ Some ( 1758602096000001 ) ,
872+ Some ( 1758602096000002 ) ,
873+ ] )
874+ . with_timezone( "+00:00" )
875+ } ) ;
876+
877+ perfectly_shredded_to_arrow_primitive_test ! (
878+ get_variant_perfectly_shredded_timestamp_micro_as_timestamp_micro,
879+ DataType :: Timestamp ( TimeUnit :: Microsecond , Some ( Arc :: from( "+00:00" ) ) ) ,
880+ perfectly_shredded_timestamp_micro_variant_array,
881+ arrow:: array:: TimestampMicrosecondArray :: from( vec![
882+ Some ( -456000 ) ,
883+ Some ( 1758602096000001 ) ,
884+ Some ( 1758602096000002 ) ,
885+ ] )
886+ . with_timezone( "+00:00" )
887+ ) ;
888+
889+ perfectly_shredded_variant_array_fn ! (
890+ perfectly_shredded_timestamp_nano_ntz_variant_array,
891+ || {
892+ arrow:: array:: TimestampNanosecondArray :: from( vec![
893+ Some ( -4999999561 ) ,
894+ Some ( 1758602096000000001 ) ,
895+ Some ( 1758602096000000002 ) ,
896+ ] )
897+ }
898+ ) ;
899+
900+ perfectly_shredded_to_arrow_primitive_test ! (
901+ get_variant_perfectly_shredded_timestamp_nano_ntz_as_timestamp_nano_ntz,
902+ DataType :: Timestamp ( TimeUnit :: Nanosecond , None ) ,
903+ perfectly_shredded_timestamp_nano_ntz_variant_array,
904+ arrow:: array:: TimestampNanosecondArray :: from( vec![
905+ Some ( -4999999561 ) ,
906+ Some ( 1758602096000000001 ) ,
907+ Some ( 1758602096000000002 ) ,
908+ ] )
909+ ) ;
910+
911+ perfectly_shredded_variant_array_fn ! ( perfectly_shredded_timestamp_nano_variant_array, || {
912+ arrow:: array:: TimestampNanosecondArray :: from( vec![
913+ Some ( -4999999561 ) ,
914+ Some ( 1758602096000000001 ) ,
915+ Some ( 1758602096000000002 ) ,
916+ ] )
917+ . with_timezone( "+00:00" )
918+ } ) ;
919+
920+ perfectly_shredded_to_arrow_primitive_test ! (
921+ get_variant_perfectly_shredded_timestamp_nano_as_timestamp_nano,
922+ DataType :: Timestamp ( TimeUnit :: Nanosecond , Some ( Arc :: from( "+00:00" ) ) ) ,
923+ perfectly_shredded_timestamp_nano_variant_array,
924+ arrow:: array:: TimestampNanosecondArray :: from( vec![
925+ Some ( -4999999561 ) ,
926+ Some ( 1758602096000000001 ) ,
927+ Some ( 1758602096000000002 ) ,
928+ ] )
929+ . with_timezone( "+00:00" )
930+ ) ;
931+
932+ perfectly_shredded_variant_array_fn ! ( perfectly_shredded_date_variant_array, || {
933+ Date32Array :: from( vec![ Some ( -12345 ) , Some ( 17586 ) , Some ( 20000 ) ] )
934+ } ) ;
935+
936+ perfectly_shredded_to_arrow_primitive_test ! (
937+ get_variant_perfectly_shredded_date_as_date,
938+ DataType :: Date32 ,
939+ perfectly_shredded_date_variant_array,
940+ Date32Array :: from( vec![ Some ( -12345 ) , Some ( 17586 ) , Some ( 20000 ) ] )
941+ ) ;
942+
845943 macro_rules! assert_variant_get_as_variant_array_with_default_option {
846944 ( $variant_array: expr, $array_expected: expr) => { {
847945 let options = GetOptions :: new( ) ;
0 commit comments