mkleen commented on code in PR #11625:
URL: https://github.com/apache/arrow-rs/pull/11625#discussion_r4303372929


##########
arrow-select/src/zip.rs:
##########
@@ -1748,4 +1750,83 @@ mod test {
         ]);
         assert_eq!(actual, &expected);
     }
+
+    #[test]
+    fn test_zip_kernel_scalar_strings_array_view_sliced_inline() {
+        // Both scalars are inlined, but each slice keeps its array's data 
buffer
+        let truthy =
+            StringViewArray::from(vec!["x", "a string longer than twelve 
bytes"]).slice(0, 1);
+        let falsy =
+            StringViewArray::from(vec!["hello", "another string longer than 
twelve"]).slice(0, 1);
+
+        let mask = BooleanArray::from(vec![true, false, true, false]);
+        let out = zip(&mask, &Scalar::new(&truthy), 
&Scalar::new(&falsy)).unwrap();
+        out.to_data().validate_full().unwrap();
+        let actual = out.as_string_view();
+        let expected = StringViewArray::from(vec!["x", "hello", "x", "hello"]);
+        assert_eq!(actual, &expected);
+    }
+
+    #[test]
+    fn test_zip_kernel_scalar_binary_array_view_sliced_inline_short() {
+        // A falsy value of at most 4 bytes keeps zero padding in view bytes 8 
to 11
+        let truthy = BinaryViewArray::from_iter_values([
+            b"x".as_slice(),
+            b"a value longer than twelve bytes",
+        ])
+        .slice(0, 1);
+        let falsy = BinaryViewArray::from_iter_values([
+            b"ab".as_slice(),
+            b"another value longer than twelve",
+        ])
+        .slice(0, 1);
+
+        let mask = BooleanArray::from(vec![false, true, false]);
+        let out = zip(&mask, &Scalar::new(&truthy), 
&Scalar::new(&falsy)).unwrap();
+        out.to_data().validate_full().unwrap();
+        let actual = out.as_binary_view();
+        let expected = BinaryViewArray::from_iter_values([b"ab".as_slice(), 
b"x", b"ab"]);
+        assert_eq!(actual, &expected);
+    }
+
+    #[test]
+    fn test_zip_kernel_scalar_strings_array_view_sliced_long_falsy() {
+        // A long falsy value must still be remapped after the truthy buffers
+        let truthy =
+            StringViewArray::from(vec!["a string longer than twelve bytes", 
"x"]).slice(0, 1);
+        let falsy =
+            StringViewArray::from(vec!["y", "another string longer than 
twelve"]).slice(1, 1);
+
+        let mask = BooleanArray::from(vec![true, false]);
+        let out = zip(&mask, &Scalar::new(&truthy), 
&Scalar::new(&falsy)).unwrap();
+        out.to_data().validate_full().unwrap();
+        let actual = out.as_string_view();
+        let expected = StringViewArray::from(vec![
+            "a string longer than twelve bytes",
+            "another string longer than twelve",
+        ]);

Review Comment:
   Sounds good.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to