@@ -485,12 +485,16 @@ impl ColumnInfo {
485485 | DataType :: UInt8
486486 | DataType :: UInt16
487487 | DataType :: UInt32
488- | DataType :: UInt64
489- | DataType :: Float32 => {
488+ | DataType :: UInt64 => {
490489 column_info. r#type = "fixed" . to_string ( ) ;
491490 column_info. precision = Some ( 38 ) ;
492491 column_info. scale = Some ( 0 ) ;
493492 }
493+ DataType :: Float16 | DataType :: Float32 | DataType :: Float64 => {
494+ column_info. r#type = "real" . to_string ( ) ;
495+ column_info. precision = Some ( 38 ) ;
496+ column_info. scale = Some ( 16 ) ;
497+ }
494498 DataType :: Decimal128 ( precision, scale) | DataType :: Decimal256 ( precision, scale) => {
495499 column_info. r#type = "fixed" . to_string ( ) ;
496500 column_info. precision = Some ( i32:: from ( * precision) ) ;
@@ -773,6 +777,25 @@ mod tests {
773777 assert_eq ! ( column_info. r#type, "text" ) ;
774778 assert_eq ! ( column_info. byte_length, None ) ;
775779 assert_eq ! ( column_info. length, None ) ;
780+
781+ let floats = [
782+ ( DataType :: Float16 , 16 , true ) ,
783+ ( DataType :: Float32 , 16 , true ) ,
784+ ( DataType :: Float64 , 16 , true ) ,
785+ ( DataType :: Float64 , 17 , false ) ,
786+ ] ;
787+ for ( float_datatype, scale, outcome) in floats {
788+ let field = Field :: new ( "test_field" , float_datatype, false ) ;
789+ let column_info = ColumnInfo :: from_field ( & field) ;
790+ assert_eq ! ( column_info. name, "test_field" ) ;
791+ assert_eq ! ( column_info. r#type, "real" ) ;
792+ assert_eq ! ( column_info. precision. unwrap( ) , 38 ) ;
793+ if outcome {
794+ assert_eq ! ( column_info. scale. unwrap( ) , scale) ;
795+ } else {
796+ assert_ne ! ( column_info. scale. unwrap( ) , scale) ;
797+ }
798+ }
776799 }
777800
778801 #[ tokio:: test]
0 commit comments