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/05/23 08:54:23 UTC

[GitHub] [arrow-rs] HaoYang670 opened a new pull request, #1725: support `min_max_binary`

HaoYang670 opened a new pull request, #1725:
URL: https://github.com/apache/arrow-rs/pull/1725

   Signed-off-by: remzi <13...@gmail.com>
   
   # Which issue does this PR close?
   
   <!---
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #1724.
   
   # What changes are included in this PR?
   1. use macro to extract some common expression.
   2. adjust the order of functions. More readable.
   3. more tests.
   
   # Are there any user-facing changes?
   2 new public functions `min_binary` and `max_binary`
   


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


[GitHub] [arrow-rs] HaoYang670 commented on a diff in pull request #1725: support `min_max_binary`

Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on code in PR #1725:
URL: https://github.com/apache/arrow-rs/pull/1725#discussion_r881036282


##########
arrow/src/compute/kernels/aggregate.rs:
##########
@@ -885,11 +893,45 @@ mod tests {
         assert!(max(&a).unwrap().is_nan());
     }
 
+    #[test]
+    fn test_binary_min_max_with_nulls() {
+        let a = BinaryArray::from(vec![
+            Some("b".as_bytes()),
+            None,
+            None,
+            Some(b"a"),
+            Some(b"c"),
+        ]);
+        assert_eq!(Some("a".as_bytes()), min_binary(&a));
+        assert_eq!(Some("c".as_bytes()), max_binary(&a));
+    }
+
+    #[test]
+    fn test_binary_min_max_no_null() {
+        let a = BinaryArray::from(vec![Some("b".as_bytes()), Some(b"a"), Some(b"c")]);
+        assert_eq!(Some("a".as_bytes()), min_binary(&a));
+        assert_eq!(Some("c".as_bytes()), max_binary(&a));
+    }
+
+    #[test]
+    fn test_binary_min_max_all_nulls() {
+        let a = BinaryArray::from(vec![None, None]);
+        assert_eq!(None, min_binary(&a));
+        assert_eq!(None, max_binary(&a));
+    }
+
+    #[test]
+    fn test_binary_min_max_1() {

Review Comment:
   We have a similar test for string:
   https://github.com/apache/arrow-rs/blob/master/arrow/src/compute/kernels/aggregate.rs#L902-L907
   
   Actually, I don't know why it is named `_1`, just copy from it.



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


[GitHub] [arrow-rs] alamb commented on pull request #1725: Add `min_binary` and `max_binary` aggregate kernels

Posted by GitBox <gi...@apache.org>.
alamb commented on PR #1725:
URL: https://github.com/apache/arrow-rs/pull/1725#issuecomment-1138905035

   Thanks everyone!


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


[GitHub] [arrow-rs] alamb merged pull request #1725: Add `min_binary` and `max_binary` aggregate kernels

Posted by GitBox <gi...@apache.org>.
alamb merged PR #1725:
URL: https://github.com/apache/arrow-rs/pull/1725


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


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1725: support `min_max_binary`

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1725:
URL: https://github.com/apache/arrow-rs/pull/1725#discussion_r880978957


##########
arrow/src/compute/kernels/aggregate.rs:
##########
@@ -885,11 +893,45 @@ mod tests {
         assert!(max(&a).unwrap().is_nan());
     }
 
+    #[test]
+    fn test_binary_min_max_with_nulls() {
+        let a = BinaryArray::from(vec![
+            Some("b".as_bytes()),
+            None,
+            None,
+            Some(b"a"),
+            Some(b"c"),
+        ]);
+        assert_eq!(Some("a".as_bytes()), min_binary(&a));
+        assert_eq!(Some("c".as_bytes()), max_binary(&a));
+    }
+
+    #[test]
+    fn test_binary_min_max_no_null() {
+        let a = BinaryArray::from(vec![Some("b".as_bytes()), Some(b"a"), Some(b"c")]);
+        assert_eq!(Some("a".as_bytes()), min_binary(&a));
+        assert_eq!(Some("c".as_bytes()), max_binary(&a));
+    }
+
+    #[test]
+    fn test_binary_min_max_all_nulls() {
+        let a = BinaryArray::from(vec![None, None]);
+        assert_eq!(None, min_binary(&a));
+        assert_eq!(None, max_binary(&a));
+    }
+
+    #[test]
+    fn test_binary_min_max_1() {

Review Comment:
   `_1`?



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