jackwener commented on code in PR #5831:
URL: https://github.com/apache/arrow-datafusion/pull/5831#discussion_r1158362515


##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -290,13 +293,30 @@ impl ExprSchemable for Expr {
     /// This function errors when it is impossible to cast the
     /// expression to the target [arrow::datatypes::DataType].
     fn cast_to<S: ExprSchema>(self, cast_to_type: &DataType, schema: &S) -> 
Result<Expr> {
+        let this_type = self.get_type(schema)?;
+        if this_type == *cast_to_type {
+            return Ok(self);
+        }
+
         // TODO(kszucs): most of the operations do not validate the type 
correctness
         // like all of the binary expressions below. Perhaps Expr should track 
the
         // type of the expression?
-        let this_type = self.get_type(schema)?;
-        if this_type == *cast_to_type {
-            Ok(self)
-        } else if can_cast_types(&this_type, cast_to_type) {
+
+        // TODO(jackwener): Handle subqueries separately, need to refactor it.

Review Comment:
   add a ticket #5877. 
   
   >  I am not sure if this comment mean you want to improve the code or if 
there is some bug / limitiation
   It's just for improving code😂.



##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -290,13 +293,30 @@ impl ExprSchemable for Expr {
     /// This function errors when it is impossible to cast the
     /// expression to the target [arrow::datatypes::DataType].
     fn cast_to<S: ExprSchema>(self, cast_to_type: &DataType, schema: &S) -> 
Result<Expr> {
+        let this_type = self.get_type(schema)?;
+        if this_type == *cast_to_type {
+            return Ok(self);
+        }
+
         // TODO(kszucs): most of the operations do not validate the type 
correctness
         // like all of the binary expressions below. Perhaps Expr should track 
the
         // type of the expression?
-        let this_type = self.get_type(schema)?;
-        if this_type == *cast_to_type {
-            Ok(self)
-        } else if can_cast_types(&this_type, cast_to_type) {
+
+        // TODO(jackwener): Handle subqueries separately, need to refactor it.

Review Comment:
   add a ticket #5877. 
   
   >  I am not sure if this comment mean you want to improve the code or if 
there is some bug / limitiation
   
   It's just for improving code😂.



-- 
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: [email protected]

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

Reply via email to