@@ -3,8 +3,8 @@ use std::sync::Arc;
33
44use datafusion:: arrow:: array:: { Array , ArrayRef , AsArray , UnionArray } ;
55use datafusion:: arrow:: datatypes:: {
6- DataType , Float32Type , Float64Type , Int16Type , Int32Type , Int64Type , Int8Type , UInt16Type ,
7- UInt32Type , UInt64Type , UInt8Type ,
6+ DataType , Float32Type , Float64Type , Int16Type , Int32Type , Int64Type , Int8Type , UInt16Type , UInt32Type , UInt64Type ,
7+ UInt8Type ,
88} ;
99use datafusion:: common:: { exec_err, plan_err, Result as DataFusionResult , ScalarValue } ;
1010use datafusion:: logical_expr:: { ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature , Volatility } ;
@@ -73,10 +73,7 @@ impl ScalarUDFImpl for JsonFromScalar {
7373 | DataType :: LargeUtf8
7474 | DataType :: Utf8View => { }
7575 _ => {
76- return plan_err ! (
77- "Unsupported type for json_from_scalar: {:?}" ,
78- arg_types[ 0 ]
79- ) ;
76+ return plan_err ! ( "Unsupported type for json_from_scalar: {:?}" , arg_types[ 0 ] ) ;
8077 }
8178 }
8279 Ok ( JsonUnion :: data_type ( ) )
@@ -141,17 +138,14 @@ fn scalar_to_json_union_field(scalar: ScalarValue) -> DataFusionResult<Option<Js
141138 ScalarValue :: Float32 ( None ) | ScalarValue :: Float64 ( None ) => Ok ( Some ( JsonUnionField :: JsonNull ) ) ,
142139
143140 // String types
144- ScalarValue :: Utf8 ( Some ( s) )
145- | ScalarValue :: LargeUtf8 ( Some ( s ) )
146- | ScalarValue :: Utf8View ( Some ( s ) ) => Ok ( Some ( JsonUnionField :: Str ( s ) ) ) ,
141+ ScalarValue :: Utf8 ( Some ( s) ) | ScalarValue :: LargeUtf8 ( Some ( s ) ) | ScalarValue :: Utf8View ( Some ( s ) ) => {
142+ Ok ( Some ( JsonUnionField :: Str ( s ) ) )
143+ }
147144 ScalarValue :: Utf8 ( None ) | ScalarValue :: LargeUtf8 ( None ) | ScalarValue :: Utf8View ( None ) => {
148145 Ok ( Some ( JsonUnionField :: JsonNull ) )
149146 }
150147
151- _ => exec_err ! (
152- "Unsupported type for json_from_scalar: {:?}" ,
153- scalar. data_type( )
154- ) ,
148+ _ => exec_err ! ( "Unsupported type for json_from_scalar: {:?}" , scalar. data_type( ) ) ,
155149 }
156150}
157151
0 commit comments