jayzhan211 commented on code in PR #13104: URL: https://github.com/apache/datafusion/pull/13104#discussion_r1816025254
########## datafusion/expr/src/type_coercion/functions.rs: ########## @@ -506,14 +494,35 @@ fn get_valid_types( ); } + let mut new_types = Vec::with_capacity(current_types.len()); for (data_type, target_type) in current_types.iter().zip(target_types.iter()) { - if !can_cast_types(data_type, target_type) { - return plan_err!("{data_type} is not coercible to {target_type}"); + if !target_type.can_decode_to(data_type) { + fn search_castable_physical_type( + data_type: &DataType, + target_type: &Arc<dyn LogicalType>, + ) -> Option<DataType> { + for physical_type in target_type.decode_types().iter() { Review Comment: @notfilippo I think we need a way to know the physical types that we are able to casted to given the Logical type. For example, if we have signature which expect Logical::String, and it accepts not only Utf8, LargeUtf8, Utf8View family but also numeric int, we need to cast the int to string so we need to know the physical types given a logical type. Therefore, I think we need to add another function that returns the physical type for LogicalType. Note that **the order matters** if we would like the cast to Utf8View then LargeUtf8 and then Utf8 in order. `select div('9', 4);` is the example in postgres that accepts numeric string, I would we may need to accept numeric string as well. What do you think? It would be nice if there is any other better approach! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org