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/08 19:43:27 UTC

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

Ismail-Maj commented on code in PR #1787:
URL: https://github.com/apache/arrow-rs/pull/1787#discussion_r892793118


##########
arrow/src/compute/kernels/concat_elements.rs:
##########
@@ -129,21 +151,50 @@ mod tests {
         let left = StringArray::from(vec!["foo", "bar"]);
         let right = StringArray::from(vec!["bar", "baz"]);
 
-        let output = concat_elements_utf8(&left, &right).unwrap();
+        let output = concat_elements_utf8(&[&left, &right]).unwrap();
 
         let expected = StringArray::from(vec!["foobar", "barbaz"]);
 
         assert_eq!(output, expected);
     }
 
     #[test]
-    fn test_string_concat_error() {
+    fn test_string_concat_error_array_length() {
         let left = StringArray::from(vec!["foo", "bar"]);
         let right = StringArray::from(vec!["baz"]);
 
-        let output = concat_elements_utf8(&left, &right);
+        let output = concat_elements_utf8(&[&left, &right]);
 
-        assert!(output.is_err());
+        assert_eq!(
+            output.unwrap_err().to_string(),
+            "Compute error: Arrays must have the same length of 2".to_string()
+        );
+    }
+
+    #[test]
+    fn test_string_concat_error_slice_length() {
+        let left = [Some("foo"), Some("bar"), None]
+            .into_iter()
+            .collect::<StringArray>();
+        assert_eq!(
+            concat_elements_utf8(&[&left]).unwrap_err().to_string(),
+            "Compute error: Arrays must have at least two elements length: 1".to_string()
+        );
+    }
+
+    #[test]
+    fn test_string_concat_multiple() {
+        let foo = &StringArray::from(vec![Some("f"), Some("o"), Some("o"), None]);
+        let bar = &StringArray::from(vec![None, Some("b"), Some("a"), Some("r")]);
+        let baz = &StringArray::from(vec![Some("b"), None, Some("a"), Some("z")]);
+
+        let output = concat_elements_utf8(&[&foo, &bar, &baz]).unwrap();

Review Comment:
   ```suggestion
           let foo = StringArray::from(vec![Some("f"), Some("o"), Some("o"), None]);
           let bar = StringArray::from(vec![None, Some("b"), Some("a"), Some("r")]);
           let baz = StringArray::from(vec![Some("b"), None, Some("a"), Some("z")]);
   
           let output = concat_elements_utf8(&[&foo, &bar, &baz]).unwrap();
   ```



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