@@ -162,9 +162,9 @@ where
162162 )
163163 . into_array ( ) ;
164164
165- match T :: DATA_TYPE {
165+ match value . data_type ( ) {
166166 DataType :: Timestamp ( time_unit, tz) => {
167- let tz = tz. map ( |s| s. to_string ( ) ) ;
167+ let tz = tz. as_ref ( ) . map ( |s| s. to_string ( ) ) ;
168168 TemporalArray :: new_timestamp ( arr, time_unit. into ( ) , tz) . into ( )
169169 }
170170 DataType :: Time32 ( time_unit) => TemporalArray :: new_time ( arr, time_unit. into ( ) ) . into ( ) ,
@@ -173,7 +173,7 @@ where
173173 DataType :: Date64 => TemporalArray :: new_date ( arr, TimeUnit :: Ms ) . into ( ) ,
174174 DataType :: Duration ( _) => unimplemented ! ( ) ,
175175 DataType :: Interval ( _) => unimplemented ! ( ) ,
176- _ => vortex_panic ! ( "Invalid temporal type: {}" , T :: DATA_TYPE ) ,
176+ _ => vortex_panic ! ( "Invalid temporal type: {}" , value . data_type ( ) ) ,
177177 }
178178}
179179
@@ -455,8 +455,8 @@ mod tests {
455455 } ;
456456 use arrow_buffer:: { BooleanBuffer , Buffer as ArrowBuffer , OffsetBuffer , ScalarBuffer } ;
457457 use arrow_schema:: { DataType , Field , Fields , Schema } ;
458- use vortex_dtype:: datetime:: TimeUnit ;
459- use vortex_dtype:: { DType , PType } ;
458+ use vortex_dtype:: datetime:: { TIMESTAMP_ID , TemporalMetadata , TimeUnit } ;
459+ use vortex_dtype:: { DType , ExtDType , Nullability , PType } ;
460460
461461 use crate :: arrays:: {
462462 DecimalVTable , ListVTable , PrimitiveVTable , StructVTable , TemporalArray , VarBinVTable ,
@@ -813,6 +813,37 @@ mod tests {
813813 assert_eq ! ( vortex_array_non_null. len( ) , 4 ) ;
814814 }
815815
816+ #[ test]
817+ fn test_timestamp_timezone_microsecond_array_conversion ( ) {
818+ let arrow_array =
819+ TimestampMicrosecondArray :: from ( vec ! [ Some ( 1000 ) , None , Some ( 3000 ) , Some ( 4000 ) ] )
820+ . with_timezone ( "UTC" ) ;
821+ let vortex_array = ArrayRef :: from_arrow ( & arrow_array, true ) ;
822+
823+ let arrow_array_non_null =
824+ TimestampMicrosecondArray :: from ( vec ! [ 1000_i64 , 2000 , 3000 , 4000 ] ) . with_timezone ( "UTC" ) ;
825+ let vortex_array_non_null = ArrayRef :: from_arrow ( & arrow_array_non_null, false ) ;
826+
827+ assert_eq ! ( vortex_array. len( ) , 4 ) ;
828+ assert_eq ! (
829+ vortex_array. dtype( ) ,
830+ & DType :: Extension ( Arc :: new( ExtDType :: new(
831+ TIMESTAMP_ID . clone( ) ,
832+ Arc :: new( DType :: Primitive ( PType :: I64 , Nullability :: Nullable ) ) ,
833+ Some ( TemporalMetadata :: Timestamp ( TimeUnit :: Us , Some ( "UTC" . to_string( ) ) ) . into( ) )
834+ ) ) )
835+ ) ;
836+ assert_eq ! ( vortex_array_non_null. len( ) , 4 ) ;
837+ assert_eq ! (
838+ vortex_array_non_null. dtype( ) ,
839+ & DType :: Extension ( Arc :: new( ExtDType :: new(
840+ TIMESTAMP_ID . clone( ) ,
841+ Arc :: new( DType :: Primitive ( PType :: I64 , Nullability :: NonNullable ) ) ,
842+ Some ( TemporalMetadata :: Timestamp ( TimeUnit :: Us , Some ( "UTC" . to_string( ) ) ) . into( ) )
843+ ) ) )
844+ ) ;
845+ }
846+
816847 #[ test]
817848 fn test_timestamp_nanosecond_array_conversion ( ) {
818849 let arrow_array =
0 commit comments