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/06/09 09:30:08 UTC

[GitHub] [arrow-rs] HaoYang670 commented on a diff in pull request #1787: Arbitrary size concat elements utf8

HaoYang670 commented on code in PR #1787:
URL: https://github.com/apache/arrow-rs/pull/1787#discussion_r893264207


##########
arrow/src/compute/kernels/concat_elements.rs:
##########
@@ -29,54 +29,76 @@ use crate::error::{ArrowError, Result};
 ///
 ///   ["Hello"] + ["World"] = ["HelloWorld"]
 ///
-///   ["a", "b"] + [None, "c"] = [None, "bc"]
+///   ["a", "b"] + [None, "c"] + [None, "d"] = [None, "bcd"]
 /// ```
 ///
-/// An error will be returned if `left` and `right` have different lengths
+/// An error will be returned if the [`StringArray`] are of different lengths.
 pub fn concat_elements_utf8<Offset: OffsetSizeTrait>(
-    left: &GenericStringArray<Offset>,
-    right: &GenericStringArray<Offset>,
+    arrays: &[&GenericStringArray<Offset>],
 ) -> Result<GenericStringArray<Offset>> {
-    if left.len() != right.len() {
+    if arrays.len() < 2 {

Review Comment:
   We should follow the pattern in `concat` kernel: https://github.com/apache/arrow-rs/blob/master/arrow/src/compute/kernels/concat.rs#L53-L61
   
   If you prefer FP style, you could write like this (not tested): 
   ```rust
   match array {
       [] => Err(...),
       [arr] => Ok((arr.slice(0, arr.len())),
       [arr, ..] => {// your code here},
   }
   ```



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