File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -3065,6 +3065,12 @@ impl FromStr for ScalarValue {
30653065 }
30663066}
30673067
3068+ impl From < String > for ScalarValue {
3069+ fn from ( value : String ) -> Self {
3070+ ScalarValue :: Utf8 ( Some ( value) )
3071+ }
3072+ }
3073+
30683074impl From < Vec < ( & str , ScalarValue ) > > for ScalarValue {
30693075 fn from ( value : Vec < ( & str , ScalarValue ) > ) -> Self {
30703076 let ( fields, scalars) : ( SchemaBuilder , Vec < _ > ) = value
@@ -4688,6 +4694,16 @@ mod tests {
46884694 ) ;
46894695 }
46904696
4697+ #[ test]
4698+ fn test_scalar_value_from_string ( ) {
4699+ let scalar = ScalarValue :: from ( "foo" ) ;
4700+ assert_eq ! ( scalar, ScalarValue :: Utf8 ( Some ( "foo" . to_string( ) ) ) ) ;
4701+ let scalar = ScalarValue :: from ( "foo" . to_string ( ) ) ;
4702+ assert_eq ! ( scalar, ScalarValue :: Utf8 ( Some ( "foo" . to_string( ) ) ) ) ;
4703+ let scalar = ScalarValue :: from_str ( "foo" ) . unwrap ( ) ;
4704+ assert_eq ! ( scalar, ScalarValue :: Utf8 ( Some ( "foo" . to_string( ) ) ) ) ;
4705+ }
4706+
46914707 #[ test]
46924708 fn test_scalar_struct ( ) {
46934709 let field_a = Arc :: new ( Field :: new ( "A" , DataType :: Int32 , false ) ) ;
You can’t perform that action at this time.
0 commit comments