File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ async fn csv_query_error() -> Result<()> {
2424 register_aggregate_csv ( & ctx) . await ?;
2525 let sql = "SELECT sin(c1) FROM aggregate_test_100" ;
2626 let plan = ctx. create_logical_plan ( sql) ;
27- assert ! ( plan. is_err( ) ) ;
27+ // NOTE(cubesql): this coercion is supported
28+ // assert!(plan.is_err());
29+ assert ! ( plan. is_ok( ) ) ;
2830 Ok ( ( ) )
2931}
3032
Original file line number Diff line number Diff line change @@ -50,11 +50,18 @@ pub fn data_types(
5050 }
5151 let valid_types = get_valid_types ( & signature. type_signature , current_types) ?;
5252
53- if valid_types
54- . iter ( )
55- . any ( |data_type| data_type == current_types)
56- {
57- return Ok ( current_types. to_vec ( ) ) ;
53+ if let Some ( types) = valid_types. iter ( ) . find ( |data_types| {
54+ if data_types. len ( ) != current_types. len ( ) {
55+ return false ;
56+ }
57+ data_types
58+ . iter ( )
59+ . zip ( current_types)
60+ . all ( |( data_type, current_type) | {
61+ data_type == current_type || matches ! ( current_type, DataType :: Null )
62+ } )
63+ } ) {
64+ return Ok ( types. clone ( ) ) ;
5865 }
5966
6067 for valid_types in valid_types {
@@ -145,6 +152,10 @@ fn maybe_data_types(
145152/// See the module level documentation for more detail on coercion.
146153pub fn can_coerce_from ( type_into : & DataType , type_from : & DataType ) -> bool {
147154 use self :: DataType :: * ;
155+ // Strings can be converted to most types implicitly
156+ if matches ! ( type_from, Utf8 | LargeUtf8 ) {
157+ return true ;
158+ }
148159 // Null can convert to most of types
149160 match type_into {
150161 Int8 => matches ! ( type_from, Null | Int8 ) ,
You can’t perform that action at this time.
0 commit comments