@@ -866,51 +866,42 @@ fn typed_value_to_variant(typed_value: &ArrayRef, index: usize) -> Variant<'_, '
866866 DataType :: Float64 => {
867867 primitive_conversion_single_value ! ( Float64Type , typed_value, index)
868868 }
869- DataType :: Timestamp ( timeunit, tz) => {
870- match ( timeunit, tz) {
871- ( TimeUnit :: Microsecond , Some ( _) ) => {
872- generic_conversion_single_value ! (
873- TimestampMicrosecondType ,
874- as_primitive,
875- |v| DateTime :: from_timestamp_micros( v) . unwrap( ) ,
876- typed_value,
877- index
878- )
879- }
880- ( TimeUnit :: Microsecond , None ) => {
881- generic_conversion_single_value ! (
882- TimestampMicrosecondType ,
883- as_primitive,
884- |v| DateTime :: from_timestamp_micros( v) . unwrap( ) . naive_utc( ) ,
885- typed_value,
886- index
887- )
888- }
889- ( TimeUnit :: Nanosecond , Some ( _) ) => {
890- generic_conversion_single_value ! (
891- TimestampNanosecondType ,
892- as_primitive,
893- DateTime :: from_timestamp_nanos,
894- typed_value,
895- index
896- )
897- }
898- ( TimeUnit :: Nanosecond , None ) => {
899- generic_conversion_single_value ! (
900- TimestampNanosecondType ,
901- as_primitive,
902- |v| DateTime :: from_timestamp_nanos( v) . naive_utc( ) ,
903- typed_value,
904- index
905- )
906- }
907- // Variant timestamp only support time unit with microsecond or nanosecond precision
908- _ => panic ! (
909- "Variant only support timestamp with microsecond or nanosecond precision"
910- ) ,
911- }
869+ DataType :: Timestamp ( TimeUnit :: Microsecond , Some ( _) ) => {
870+ generic_conversion_single_value ! (
871+ TimestampMicrosecondType ,
872+ as_primitive,
873+ |v| DateTime :: from_timestamp_micros( v) . unwrap( ) ,
874+ typed_value,
875+ index
876+ )
877+ }
878+ DataType :: Timestamp ( TimeUnit :: Microsecond , None ) => {
879+ generic_conversion_single_value ! (
880+ TimestampMicrosecondType ,
881+ as_primitive,
882+ |v| DateTime :: from_timestamp_micros( v) . unwrap( ) . naive_utc( ) ,
883+ typed_value,
884+ index
885+ )
886+ }
887+ DataType :: Timestamp ( TimeUnit :: Nanosecond , Some ( _) ) => {
888+ generic_conversion_single_value ! (
889+ TimestampNanosecondType ,
890+ as_primitive,
891+ DateTime :: from_timestamp_nanos,
892+ typed_value,
893+ index
894+ )
895+ }
896+ DataType :: Timestamp ( TimeUnit :: Nanosecond , None ) => {
897+ generic_conversion_single_value ! (
898+ TimestampNanosecondType ,
899+ as_primitive,
900+ |v| DateTime :: from_timestamp_nanos( v) . naive_utc( ) ,
901+ typed_value,
902+ index
903+ )
912904 }
913-
914905 // todo other types here (note this is very similar to cast_to_variant.rs)
915906 // so it would be great to figure out how to share this code
916907 _ => {
0 commit comments