kou commented on code in PR #34902:
URL: https://github.com/apache/arrow/pull/34902#discussion_r1159039407


##########
ruby/red-arrow/test/test-slicer.rb:
##########
@@ -484,4 +484,38 @@ def setup
 7         256  true   
     TABLE
   end
+
+  sub_test_case "MatchSubstringOptions family" do
+    def setup
+      @string_table = Arrow::Table.new(
+        index: [*1..5],
+        string: ["array", "Arrow", "carrot", nil, "window"]
+      )
+    end
+
+    test("match_substring") do
+      sliced_table = @string_table.slice do |slicer|
+        slicer.string.match_substring("arr")
+      end
+      assert_equal(<<~TABLE, sliced_table.to_s)
+        index  string
+0           1  array 
+1           3  carrot
+2      (null)  (null)
+      TABLE
+    end
+
+    test("match_substring with ignore_case option") do

Review Comment:
   Could you use simple Ruby syntax like test name instead of English?
   I like the style because it's easy to read for me :-)
   
   ```suggestion
       test("match_substring(ignore_case:)") do
   ```



##########
ruby/red-arrow/test/test-slicer.rb:
##########
@@ -484,4 +484,38 @@ def setup
 7         256  true   
     TABLE
   end
+
+  sub_test_case "MatchSubstringOptions family" do
+    def setup
+      @string_table = Arrow::Table.new(
+        index: [*1..5],

Review Comment:
   Why do we need this?



##########
ruby/red-arrow/lib/arrow/slicer.rb:
##########
@@ -351,5 +356,22 @@ def evaluate
         BooleanArray.new(raw_array)
       end
     end
+
+    class MatchSubstringFamilyCondition < Condition
+      def initialize(function, column, substring, ignore_case)
+        @function = function
+        @column = column
+        @options = MatchSubstringOptions.new
+        @options.pattern = substring
+        @options.ignore_case = ignore_case
+      end
+
+      def evaluate
+        case @function
+        when "match_substring"
+          Function.find("match_substring").execute([@column.data], 
@options).value
+        end

Review Comment:
   ```suggestion
           Function.find(@function).execute([@column.data], @options).value
   ```



##########
ruby/red-arrow/test/test-slicer.rb:
##########
@@ -484,4 +484,38 @@ def setup
 7         256  true   
     TABLE
   end
+
+  sub_test_case "MatchSubstringOptions family" do
+    def setup
+      @string_table = Arrow::Table.new(

Review Comment:
   I think that `string_` is redundant. Because we process only string in this 
context.



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