alamb commented on a change in pull request #8400:
URL: https://github.com/apache/arrow/pull/8400#discussion_r501795062



##########
File path: rust/datafusion/src/logical_plan/mod.rs
##########
@@ -323,12 +324,13 @@ impl Expr {
     ///
     /// # Errors
     ///
-    /// This function errors when it is impossible to cast the expression to 
the target [arrow::datatypes::DataType].
+    /// This function errors when it is impossible to cast the
+    /// expression to the target [arrow::datatypes::DataType].
     pub fn cast_to(&self, cast_to_type: &DataType, schema: &Schema) -> 
Result<Expr> {
         let this_type = self.get_type(schema)?;
         if this_type == *cast_to_type {
             Ok(self.clone())
-        } else if can_coerce_from(cast_to_type, &this_type) {
+        } else if can_cast_types(&this_type, cast_to_type) {

Review comment:
       the idea is to use a common `can_cast_types` function to detect valid 
casts at plan time, and make `can_cast_types` consistent with the arrow cast 
kernel




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to