@@ -774,7 +774,7 @@ impl ScalarValue {
774774
775775 /// Returns a [`ScalarValue::Utf8`] representing `val`
776776 pub fn new_utf8 ( val : impl Into < String > ) -> Self {
777- ScalarValue :: Utf8 ( Some ( val. into ( ) ) )
777+ ScalarValue :: from ( val. into ( ) )
778778 }
779779
780780 /// Returns a [`ScalarValue::IntervalYearMonth`] representing
@@ -2699,7 +2699,7 @@ impl ScalarValue {
26992699
27002700 /// Try to parse `value` into a ScalarValue of type `target_type`
27012701 pub fn try_from_string ( value : String , target_type : & DataType ) -> Result < Self > {
2702- let value = ScalarValue :: Utf8 ( Some ( value) ) ;
2702+ let value = ScalarValue :: from ( value) ;
27032703 let cast_options = CastOptions {
27042704 safe : false ,
27052705 format_options : Default :: default ( ) ,
@@ -3581,9 +3581,9 @@ mod tests {
35813581 #[ test]
35823582 fn test_list_to_array_string ( ) {
35833583 let scalars = vec ! [
3584- ScalarValue :: Utf8 ( Some ( String :: from( "rust" ) ) ) ,
3585- ScalarValue :: Utf8 ( Some ( String :: from( "arrow" ) ) ) ,
3586- ScalarValue :: Utf8 ( Some ( String :: from( "data-fusion" ) ) ) ,
3584+ ScalarValue :: from( "rust" ) ,
3585+ ScalarValue :: from( "arrow" ) ,
3586+ ScalarValue :: from( "data-fusion" ) ,
35873587 ] ;
35883588
35893589 let array = ScalarValue :: new_list ( scalars. as_slice ( ) , & DataType :: Utf8 ) ;
@@ -4722,7 +4722,7 @@ mod tests {
47224722 Some ( vec ! [
47234723 ScalarValue :: Int32 ( Some ( 23 ) ) ,
47244724 ScalarValue :: Boolean ( Some ( false ) ) ,
4725- ScalarValue :: Utf8 ( Some ( "Hello" . to_string ( ) ) ) ,
4725+ ScalarValue :: from ( "Hello" ) ,
47264726 ScalarValue :: from( vec![
47274727 ( "e" , ScalarValue :: from( 2i16 ) ) ,
47284728 ( "f" , ScalarValue :: from( 3i64 ) ) ,
@@ -4915,17 +4915,17 @@ mod tests {
49154915
49164916 // Define struct scalars
49174917 let s0 = ScalarValue :: from ( vec ! [
4918- ( "A" , ScalarValue :: Utf8 ( Some ( String :: from( "First" ) ) ) ) ,
4918+ ( "A" , ScalarValue :: from( "First" ) ) ,
49194919 ( "primitive_list" , l0) ,
49204920 ] ) ;
49214921
49224922 let s1 = ScalarValue :: from ( vec ! [
4923- ( "A" , ScalarValue :: Utf8 ( Some ( String :: from( "Second" ) ) ) ) ,
4923+ ( "A" , ScalarValue :: from( "Second" ) ) ,
49244924 ( "primitive_list" , l1) ,
49254925 ] ) ;
49264926
49274927 let s2 = ScalarValue :: from ( vec ! [
4928- ( "A" , ScalarValue :: Utf8 ( Some ( String :: from( "Third" ) ) ) ) ,
4928+ ( "A" , ScalarValue :: from( "Third" ) ) ,
49294929 ( "primitive_list" , l2) ,
49304930 ] ) ;
49314931
@@ -5212,7 +5212,7 @@ mod tests {
52125212 check_scalar_cast ( ScalarValue :: Float64 ( None ) , DataType :: Int16 ) ;
52135213
52145214 check_scalar_cast (
5215- ScalarValue :: Utf8 ( Some ( "foo" . to_string ( ) ) ) ,
5215+ ScalarValue :: from ( "foo" ) ,
52165216 DataType :: Dictionary ( Box :: new ( DataType :: Int32 ) , Box :: new ( DataType :: Utf8 ) ) ,
52175217 ) ;
52185218
@@ -5493,10 +5493,7 @@ mod tests {
54935493 ( ScalarValue :: Int8 ( None ) , ScalarValue :: Int16 ( Some ( 1 ) ) ) ,
54945494 ( ScalarValue :: Int8 ( Some ( 1 ) ) , ScalarValue :: Int16 ( None ) ) ,
54955495 // Unsupported types
5496- (
5497- ScalarValue :: Utf8 ( Some ( "foo" . to_string ( ) ) ) ,
5498- ScalarValue :: Utf8 ( Some ( "bar" . to_string ( ) ) ) ,
5499- ) ,
5496+ ( ScalarValue :: from ( "foo" ) , ScalarValue :: from ( "bar" ) ) ,
55005497 (
55015498 ScalarValue :: Boolean ( Some ( true ) ) ,
55025499 ScalarValue :: Boolean ( Some ( false ) ) ,
0 commit comments