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


##########
ruby/red-arrow/lib/arrow/slicer.rb:
##########
@@ -162,6 +162,11 @@ def select(&block)
       def reject(&block)
         RejectCondition.new(@column, block)
       end
+
+      def match_substring(substring, ignore_case: false)
+        MatchSubstringCondition.new("match_substring",

Review Comment:
   How about `MatchSubstringFamilyCondition` because this is not only for 
`match_substring`?



##########
ruby/red-arrow/lib/arrow/slicer.rb:
##########
@@ -351,5 +356,33 @@ def evaluate
         BooleanArray.new(raw_array)
       end
     end
+
+    class MatchSubstringCondition < Condition
+      def initialize(function, column, pattern, ignore_case, invert: false)
+        @function = function
+        @column = column
+        @options = MatchSubstringOptions.new
+        @options.pattern = pattern
+        @options.ignore_case = ignore_case
+        @invert = invert
+      end
+
+      def !@
+        MatchSubstringCondition.new(@function,
+                                    @column,
+                                    @options.pattern,
+                                    @options.ignore_case?,
+                                    invert: !@invert)
+      end
+
+      def evaluate
+        datum = Function.find(@function).execute([@column.data], @options)
+        if @invert
+          Function.find("invert").execute([datum]).value
+        else
+          datum.value
+        end

Review Comment:
   It's not a strong opinion but the following may be simpler:
   
   ```suggestion
           if @invert
             datum = Function.find("invert").execute([datum])
           end
           datum.value
   ```



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