@@ -404,7 +404,7 @@ pub fn arrow_to_column_type(arrow_type: DataType) -> Result<ColumnType, CubeErro
404404 DataType :: Utf8 | DataType :: LargeUtf8 => Ok ( ColumnType :: String ) ,
405405 DataType :: Date32 => Ok ( ColumnType :: Date ( false ) ) ,
406406 DataType :: Date64 => Ok ( ColumnType :: Date ( true ) ) ,
407- DataType :: Timestamp ( _, _) => Ok ( ColumnType :: String ) ,
407+ DataType :: Timestamp ( _, _) => Ok ( ColumnType :: Timestamp ) ,
408408 DataType :: Interval ( unit) => Ok ( ColumnType :: Interval ( unit) ) ,
409409 DataType :: Float16 | DataType :: Float32 | DataType :: Float64 => Ok ( ColumnType :: Double ) ,
410410 DataType :: Boolean => Ok ( ColumnType :: Boolean ) ,
@@ -794,4 +794,35 @@ mod tests {
794794 serde_json:: to_string( & frame. data) . unwrap( )
795795 ) ;
796796 }
797+
798+ #[ test]
799+ fn test_arrow_to_column_type ( ) {
800+ let cases = vec ! [
801+ ( DataType :: Binary , ColumnType :: Blob ) ,
802+ ( DataType :: Utf8 , ColumnType :: String ) ,
803+ ( DataType :: LargeUtf8 , ColumnType :: String ) ,
804+ ( DataType :: Date32 , ColumnType :: Date ( false ) ) ,
805+ ( DataType :: Date64 , ColumnType :: Date ( true ) ) ,
806+ ( DataType :: Timestamp ( TimeUnit :: Second , None ) , ColumnType :: Timestamp ) ,
807+ ( DataType :: Interval ( IntervalUnit :: YearMonth ) , ColumnType :: Interval ( IntervalUnit :: YearMonth ) ) ,
808+ ( DataType :: Float16 , ColumnType :: Double ) ,
809+ ( DataType :: Float32 , ColumnType :: Double ) ,
810+ ( DataType :: Float64 , ColumnType :: Double ) ,
811+ ( DataType :: Boolean , ColumnType :: Boolean ) ,
812+ ( DataType :: Int32 , ColumnType :: Int32 ) ,
813+ ( DataType :: UInt32 , ColumnType :: Int32 ) ,
814+ ( DataType :: Int8 , ColumnType :: Int64 ) ,
815+ ( DataType :: Int16 , ColumnType :: Int64 ) ,
816+ ( DataType :: Int64 , ColumnType :: Int64 ) ,
817+ ( DataType :: UInt8 , ColumnType :: Int64 ) ,
818+ ( DataType :: UInt16 , ColumnType :: Int64 ) ,
819+ ( DataType :: UInt64 , ColumnType :: Int64 ) ,
820+ ( DataType :: Null , ColumnType :: String ) ,
821+ ] ;
822+
823+ for ( arrow_type, expected_column_type) in cases {
824+ let result = arrow_to_column_type ( arrow_type. clone ( ) ) . unwrap ( ) ;
825+ assert_eq ! ( result, expected_column_type, "Failed for {:?}" , arrow_type) ;
826+ }
827+ }
797828}
0 commit comments