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/04/01 20:15:22 UTC

[GitHub] [arrow-datafusion] Dandandan commented on a change in pull request #2128: MINOR: fix concat_ws corner bug

Dandandan commented on a change in pull request #2128:
URL: https://github.com/apache/arrow-datafusion/pull/2128#discussion_r840891530



##########
File path: datafusion/physical-expr/src/string_expressions.rs
##########
@@ -343,18 +343,17 @@ pub fn concat_ws(args: &[ArrayRef]) -> Result<ArrayRef> {
         .enumerate()
         .map(|(index, x)| {
             x.map(|sep: &str| {
-                let mut owned_string: String = "".to_owned();
-                for arg_index in 1..args.len() {
-                    let arg = &args[arg_index];
-                    if !arg.is_null(index) {
-                        owned_string.push_str(arg.value(index));
-                        // if not last push separator
-                        if arg_index != args.len() - 1 {
-                            owned_string.push_str(sep);
+                let string_vec = args[1..]
+                    .iter()
+                    .flat_map(|arg| {
+                        if !arg.is_null(index) {
+                            vec![arg.value(index)]
+                        } else {
+                            vec![]

Review comment:
       ```suggestion
                           if !arg.is_null(index) {
                               Some(arg.value(index))
                           } else {
                               None
                           }
   ```
   




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