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/05 21:34:37 UTC

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

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


##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -816,6 +830,55 @@ mod test {
         Ok(())
     }
 
+    #[test]
+    fn concat_for_type_coercion() -> Result<()> {
+        use datafusion_expr::BuiltinScalarFunction::{Concat, ConcatWithSeparator};
+
+        let empty = empty_with_type(DataType::Utf8);
+        let args = vec![col("a"), lit("b"), lit(true), lit(false), lit(13)];
+
+        // concat
+        {
+            let expr = Expr::ScalarFunction {
+                fun: Concat,
+                args: args.clone(),
+            };

Review Comment:
   I think you can use the `concat` builder function here https://docs.rs/datafusion/12.0.0/datafusion/logical_plan/fn.concat.html
   
   ```suggestion
               let expr = concat(args.clone());
   ```
   



##########
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:
   I wonder if we should do something with `LargeUtf8`?
   
   Also, would it make sense to check the types before `clone()`ing them to do a cast that might not be needed?



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