You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kou (via GitHub)" <gi...@apache.org> on 2023/04/05 08:13:00 UTC
[GitHub] [arrow] kou commented on a diff in pull request #34902: GH-34819: [Ruby] Add Slicer::ColumnCondition#match_substring
kou commented on code in PR #34902:
URL: https://github.com/apache/arrow/pull/34902#discussion_r1158175613
##########
ruby/red-arrow/test/test-slicer.rb:
##########
@@ -484,4 +488,29 @@ def setup
7 256 true
TABLE
end
+
+ test("match_substring") do
Review Comment:
Could you create sub test case and move `@string_table = ...` to here?
```ruby
sub_test_case("#match_substring") do
def setup
super # Not needed?
# index: is needed?
@table = Arrow::Table.new(index: [*1..5], string: ["array", "Arrow", "carrot", nil, "window"])
end
test("String") do
end
test("String, ignore_case:") do
end
end
```
##########
ruby/red-arrow/lib/arrow/slicer.rb:
##########
@@ -351,5 +355,18 @@ def evaluate
BooleanArray.new(raw_array)
end
end
+
+ class MatchSubstringCondition < Condition
+ def initialize(column, substring, ignore_case)
+ @column = column
+ @options = MatchSubstringOptions.new
+ @options.pattern = substring
+ @options.ignore_case = true if ignore_case
Review Comment:
```suggestion
@options.ignore_case = ignore_case
```
##########
ruby/red-arrow/lib/arrow/slicer.rb:
##########
@@ -162,6 +162,10 @@ def select(&block)
def reject(&block)
RejectCondition.new(@column, block)
end
+
+ def match_substring(substring, ignore_case: false)
+ MatchSubstringCondition.new(@column, substring, ignore_case)
Review Comment:
How about making this reusable for other `match_substring` family functions?
```suggestion
MatchSubstringFamilyCondition.new("match_substring", @column, substring, ignore_case)
```
--
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