@@ -146,7 +146,9 @@ impl TryFrom<&DataType> for Type {
146146 fn try_from ( value : & DataType ) -> Result < Self , Self :: Error > {
147147 match value {
148148 DataType :: Boolean => Ok ( Type :: Primitive ( PrimitiveType :: Boolean ) ) ,
149- DataType :: Int32 => Ok ( Type :: Primitive ( PrimitiveType :: Int ) ) ,
149+ DataType :: Int8 | DataType :: Int16 | DataType :: Int32 => {
150+ Ok ( Type :: Primitive ( PrimitiveType :: Int ) )
151+ }
150152 DataType :: Int64 => Ok ( Type :: Primitive ( PrimitiveType :: Long ) ) ,
151153 DataType :: Float32 => Ok ( Type :: Primitive ( PrimitiveType :: Float ) ) ,
152154 DataType :: Float64 => Ok ( Type :: Primitive ( PrimitiveType :: Double ) ) ,
@@ -536,6 +538,10 @@ mod tests {
536538 PARQUET_FIELD_ID_META_KEY . to_string( ) ,
537539 "2" . to_string( ) ,
538540 ) ] ) ) ,
541+ Field :: new( "field3" , DataType :: Int16 , true ) . with_metadata( HashMap :: from( [ (
542+ PARQUET_FIELD_ID_META_KEY . to_string( ) ,
543+ "3" . to_string( ) ,
544+ ) ] ) ) ,
539545 ] ) ;
540546
541547 let struct_type: StructType = ( & arrow_schema) . try_into ( ) . unwrap ( ) ;
@@ -554,6 +560,13 @@ mod tests {
554560 struct_type[ 1 ] . field_type,
555561 Type :: Primitive ( PrimitiveType :: String )
556562 ) ;
563+ assert_eq ! ( struct_type[ 2 ] . id, 3 ) ;
564+ assert_eq ! ( struct_type[ 2 ] . name, "field3" ) ;
565+ assert ! ( !struct_type[ 2 ] . required) ;
566+ assert_eq ! (
567+ struct_type[ 2 ] . field_type,
568+ Type :: Primitive ( PrimitiveType :: Int )
569+ ) ;
557570 }
558571
559572 #[ test]
@@ -844,7 +857,7 @@ mod tests {
844857
845858 #[ test]
846859 fn test_arrow_schema_to_struct_type_unsupported_datatype ( ) {
847- let arrow_schema = ArrowSchema :: new ( vec ! [ Field :: new( "field1" , DataType :: Int8 , false )
860+ let arrow_schema = ArrowSchema :: new ( vec ! [ Field :: new( "field1" , DataType :: UInt8 , false )
848861 . with_metadata( HashMap :: from( [ (
849862 PARQUET_FIELD_ID_META_KEY . to_string( ) ,
850863 "1" . to_string( ) ,
0 commit comments