@@ -608,26 +608,38 @@ pub fn schema_to_arrow_schema(schema: &crate::spec::Schema) -> crate::Result<Arr
608608
609609/// Convert Iceberg Datum to Arrow Datum.
610610pub ( crate ) fn get_arrow_datum ( datum : & Datum ) -> Result < Box < dyn ArrowDatum + Send > > {
611- match datum. literal ( ) {
612- PrimitiveLiteral :: Boolean ( value) => Ok ( Box :: new ( BooleanArray :: new_scalar ( * value) ) ) ,
613- PrimitiveLiteral :: Int ( value) => Ok ( Box :: new ( Int32Array :: new_scalar ( * value) ) ) ,
614- PrimitiveLiteral :: Long ( value) => Ok ( Box :: new ( Int64Array :: new_scalar ( * value) ) ) ,
615- PrimitiveLiteral :: Float ( value) => Ok ( Box :: new ( Float32Array :: new_scalar ( value. as_f32 ( ) ) ) ) ,
616- PrimitiveLiteral :: Double ( value) => Ok ( Box :: new ( Float64Array :: new_scalar ( value. as_f64 ( ) ) ) ) ,
617- PrimitiveLiteral :: String ( value) => Ok ( Box :: new ( StringArray :: new_scalar ( value. as_str ( ) ) ) ) ,
618- PrimitiveLiteral :: Timestamp ( value) => {
611+ match ( datum. data_type ( ) , datum. literal ( ) ) {
612+ ( PrimitiveType :: Boolean , PrimitiveLiteral :: Boolean ( value) ) => {
613+ Ok ( Box :: new ( BooleanArray :: new_scalar ( * value) ) )
614+ }
615+ ( PrimitiveType :: Int , PrimitiveLiteral :: Int ( value) ) => {
616+ Ok ( Box :: new ( Int32Array :: new_scalar ( * value) ) )
617+ }
618+ ( PrimitiveType :: Long , PrimitiveLiteral :: Long ( value) ) => {
619+ Ok ( Box :: new ( Int64Array :: new_scalar ( * value) ) )
620+ }
621+ ( PrimitiveType :: Float , PrimitiveLiteral :: Float ( value) ) => {
622+ Ok ( Box :: new ( Float32Array :: new_scalar ( value. as_f32 ( ) ) ) )
623+ }
624+ ( PrimitiveType :: Double , PrimitiveLiteral :: Double ( value) ) => {
625+ Ok ( Box :: new ( Float64Array :: new_scalar ( value. as_f64 ( ) ) ) )
626+ }
627+ ( PrimitiveType :: String , PrimitiveLiteral :: String ( value) ) => {
628+ Ok ( Box :: new ( StringArray :: new_scalar ( value. as_str ( ) ) ) )
629+ }
630+ ( PrimitiveType :: Timestamp , PrimitiveLiteral :: Long ( value) ) => {
619631 Ok ( Box :: new ( TimestampMicrosecondArray :: new_scalar ( * value) ) )
620632 }
621- PrimitiveLiteral :: Timestamptz ( value) => Ok ( Box :: new ( Scalar :: new (
633+ ( PrimitiveType :: Timestamptz , PrimitiveLiteral :: Long ( value) ) => Ok ( Box :: new ( Scalar :: new (
622634 PrimitiveArray :: < TimestampMicrosecondType > :: new ( vec ! [ * value; 1 ] . into ( ) , None )
623635 . with_timezone ( "UTC" ) ,
624636 ) ) ) ,
625637
626- l => Err ( Error :: new (
638+ ( typ , _ ) => Err ( Error :: new (
627639 ErrorKind :: FeatureUnsupported ,
628640 format ! (
629641 "Converting datum from type {:?} to arrow not supported yet." ,
630- l
642+ typ
631643 ) ,
632644 ) ) ,
633645 }
0 commit comments