You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/06 02:01:37 UTC

[GitHub] [arrow-datafusion] HaoYang670 commented on a diff in pull request #3721: Add type coercion rule for `concat` and `concat_ws`

HaoYang670 commented on code in PR #3721:
URL: https://github.com/apache/arrow-datafusion/pull/3721#discussion_r988486604


##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -398,6 +398,20 @@ impl ExprRewriter for TypeCoercionRewriter {
                     }
                 }
             }
+            Expr::ScalarFunction { fun, args } => match fun {
+                BuiltinScalarFunction::Concat
+                | BuiltinScalarFunction::ConcatWithSeparator => {
+                    let new_args = args

Review Comment:
   > would it make sense to check the types before clone()ing them to do a cast that might not be needed?
   
   I think this has been done in the `cast_to` function:
   ```rust
   fn cast_to<S: ExprSchema>(self, cast_to_type: &DataType, schema: &S) -> Result<Expr> {
       // 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)
   ...
   }
   ```



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org