This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new be79766  ARROW-14031: [Ruby] Use min and max separately
be79766 is described below

commit be79766759401e83fac8ed38fa3718afca9c476f
Author: Sutou Kouhei <[email protected]>
AuthorDate: Sun Sep 19 09:10:54 2021 +0900

    ARROW-14031: [Ruby] Use min and max separately
    
    Closes #11179 from kou/ruby-use-min-max
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 ruby/red-arrow/lib/arrow/group.rb | 11 +++++++---
 ruby/red-arrow/test/test-group.rb | 45 ++++++++++++++++++++++++++++-----------
 2 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/ruby/red-arrow/lib/arrow/group.rb 
b/ruby/red-arrow/lib/arrow/group.rb
index c83b760..7827ac0 100644
--- a/ruby/red-arrow/lib/arrow/group.rb
+++ b/ruby/red-arrow/lib/arrow/group.rb
@@ -38,8 +38,12 @@ module Arrow
       aggregate(*build_aggregations("hash_mean", target_names))
     end
 
-    def min_max(*target_names)
-      aggregate(*build_aggregations("hash_min_max", target_names))
+    def min(*target_names)
+      aggregate(*build_aggregations("hash_min", target_names))
+    end
+
+    def max(*target_names)
+      aggregate(*build_aggregations("hash_max", target_names))
     end
 
     def stddev(*target_names)
@@ -94,7 +98,8 @@ module Arrow
             "hash_stddev",
             "hash_variance",
             # "hash_tdigest",
-            "hash_min_max",
+            "hash_min",
+            "hash_max",
             "hash_any",
             "hash_all",
           ]
diff --git a/ruby/red-arrow/test/test-group.rb 
b/ruby/red-arrow/test/test-group.rb
index f715e9e..2823977 100644
--- a/ruby/red-arrow/test/test-group.rb
+++ b/ruby/red-arrow/test/test-group.rb
@@ -123,23 +123,44 @@ class GroupTest < Test::Unit::TestCase
     end
   end
 
-  sub_test_case("#min_max") do
+  sub_test_case("#min") do
     test("single") do
-      assert_equal(<<-TABLE, @table.group(:group_key1).min_max.to_s)
-       min_max(group_key2)                   min_max(int)         
min_max(uint)                            min_max(float)      group_key1
-0      {min: 1, max: 1}        {min:     -2, max:     -1}      {min: 1, max: 
1}        {min:   2.200000, max:   2.200000}               1
-1      {min: 1, max: 1}        {min: (null), max: (null)}      {min: 3, max: 
3}        {min:   3.300000, max:   3.300000}               2
-2      {min: 1, max: 2}        {min:     -6, max:     -4}      {min: 4, max: 
6}        {min:   4.400000, max:   6.600000}               3
+      assert_equal(<<-TABLE, @table.group(:group_key1).min.to_s)
+       min(group_key2) min(int)        min(uint)       min(float)      
group_key1
+0                    1       -2                1         2.200000              
 1
+1                    1   (null)                3         3.300000              
 2
+2                    1       -6                4         4.400000              
 3
       TABLE
     end
 
     test("multiple") do
-      assert_equal(<<-TABLE, @table.group(:group_key1, 
:group_key2).min_max.to_s)
-                     min_max(int)         min_max(uint)                        
    min_max(float)      group_key1      group_key2
-0      {min:     -2, max:     -1}      {min: 1, max: 1}        {min:   
2.200000, max:   2.200000}               1               1
-1      {min: (null), max: (null)}      {min: 3, max: 3}        {min:   
3.300000, max:   3.300000}               2               1
-2      {min:     -4, max:     -4}      {min: 4, max: 4}        {min:   
4.400000, max:   4.400000}               3               1
-3      {min:     -6, max:     -5}      {min: 5, max: 6}        {min:   
5.500000, max:   6.600000}               3               2
+      assert_equal(<<-TABLE, @table.group(:group_key1, :group_key2).min.to_s)
+       min(int)        min(uint)       min(float)      group_key1      
group_key2
+0            -2                1         2.200000               1              
 1
+1        (null)                3         3.300000               2              
 1
+2            -4                4         4.400000               3              
 1
+3            -6                5         5.500000               3              
 2
+      TABLE
+    end
+  end
+
+  sub_test_case("#max") do
+    test("single") do
+      assert_equal(<<-TABLE, @table.group(:group_key1).max.to_s)
+       max(group_key2) max(int)        max(uint)       max(float)      
group_key1
+0                    1       -1                1         2.200000              
 1
+1                    1   (null)                3         3.300000              
 2
+2                    2       -4                6         6.600000              
 3
+      TABLE
+    end
+
+    test("multiple") do
+      assert_equal(<<-TABLE, @table.group(:group_key1, :group_key2).max.to_s)
+       max(int)        max(uint)       max(float)      group_key1      
group_key2
+0            -1                1         2.200000               1              
 1
+1        (null)                3         3.300000               2              
 1
+2            -4                4         4.400000               3              
 1
+3            -5                6         6.600000               3              
 2
       TABLE
     end
   end

Reply via email to