@@ -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,41 @@ 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+ (
807+ DataType :: Timestamp ( TimeUnit :: Second , None ) ,
808+ ColumnType :: Timestamp ,
809+ ) ,
810+ (
811+ DataType :: Interval ( IntervalUnit :: YearMonth ) ,
812+ ColumnType :: Interval ( IntervalUnit :: YearMonth ) ,
813+ ) ,
814+ ( DataType :: Float16 , ColumnType :: Double ) ,
815+ ( DataType :: Float32 , ColumnType :: Double ) ,
816+ ( DataType :: Float64 , ColumnType :: Double ) ,
817+ ( DataType :: Boolean , ColumnType :: Boolean ) ,
818+ ( DataType :: Int32 , ColumnType :: Int32 ) ,
819+ ( DataType :: UInt32 , ColumnType :: Int32 ) ,
820+ ( DataType :: Int8 , ColumnType :: Int64 ) ,
821+ ( DataType :: Int16 , ColumnType :: Int64 ) ,
822+ ( DataType :: Int64 , ColumnType :: Int64 ) ,
823+ ( DataType :: UInt8 , ColumnType :: Int64 ) ,
824+ ( DataType :: UInt16 , ColumnType :: Int64 ) ,
825+ ( DataType :: UInt64 , ColumnType :: Int64 ) ,
826+ ( DataType :: Null , ColumnType :: String ) ,
827+ ] ;
828+
829+ for ( arrow_type, expected_column_type) in cases {
830+ let result = arrow_to_column_type ( arrow_type. clone ( ) ) . unwrap ( ) ;
831+ assert_eq ! ( result, expected_column_type, "Failed for {:?}" , arrow_type) ;
832+ }
833+ }
797834}
0 commit comments