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/12/25 21:20:00 UTC
[GitHub] [arrow] kou commented on a diff in pull request #15088: GH-15084: [Ruby] Use common keys when keys.nil? in Table#join
kou commented on code in PR #15088:
URL: https://github.com/apache/arrow/pull/15088#discussion_r1056998664
##########
ruby/red-arrow/lib/arrow/table.rb:
##########
@@ -492,7 +504,8 @@ def pack
# @macro join_common_after
#
# @since 7.0.0
- def join(right, keys, type: :inner, left_outputs: nil, right_outputs: nil)
+ def join(right, keys = nil, type: :inner, left_outputs: nil, right_outputs: nil)
Review Comment:
Could you remove spaces around `=` for default value? We use the style in this project.
```suggestion
def join(right, keys=nil, type: :inner, left_outputs: nil, right_outputs: nil)
```
##########
ruby/red-arrow/test/test-table.rb:
##########
@@ -1049,27 +1049,29 @@ def setup
number: [10, 20, 30])
table2 = Arrow::Table.new(key: [3, 1],
string: ["three", "one"])
- assert_equal(Arrow::Table.new([
- ["key", [1, 3]],
- ["number", [10, 30]],
- ["key", [1, 3]],
- ["string", ["one", "three"]],
- ]),
- table1.join(table2, "key"))
+ expected = Arrow::Table.new([
+ ["key", [1, 3]],
+ ["number", [10, 30]],
+ ["key", [1, 3]],
+ ["string", ["one", "three"]]
+ ])
+ assert_equal(expected, table1.join(table2, "key"))
+ assert_equal(expected, table1.join(table2))
end
test("keys: Symbol") do
table1 = Arrow::Table.new(key: [1, 2, 3],
number: [10, 20, 30])
table2 = Arrow::Table.new(key: [3, 1],
string: ["three", "one"])
- assert_equal(Arrow::Table.new([
- ["key", [1, 3]],
- ["number", [10, 30]],
- ["key", [1, 3]],
- ["string", ["one", "three"]],
- ]),
- table1.join(table2, :key))
+ expected = Arrow::Table.new([
+ ["key", [1, 3]],
+ ["number", [10, 30]],
+ ["key", [1, 3]],
+ ["string", ["one", "three"]]
+ ])
+ assert_equal(expected, table1.join(table2, :key))
+ assert_equal(expected, table1.join(table2))
Review Comment:
This is redundant. Because it's the same assertion as the above newly added assertion.
##########
ruby/red-arrow/test/test-table.rb:
##########
@@ -1049,27 +1049,29 @@ def setup
number: [10, 20, 30])
table2 = Arrow::Table.new(key: [3, 1],
string: ["three", "one"])
- assert_equal(Arrow::Table.new([
- ["key", [1, 3]],
- ["number", [10, 30]],
- ["key", [1, 3]],
- ["string", ["one", "three"]],
- ]),
- table1.join(table2, "key"))
+ expected = Arrow::Table.new([
+ ["key", [1, 3]],
+ ["number", [10, 30]],
+ ["key", [1, 3]],
+ ["string", ["one", "three"]]
+ ])
+ assert_equal(expected, table1.join(table2, "key"))
+ assert_equal(expected, table1.join(table2))
Review Comment:
Could you create a new test without changing existing `keys: String` test?
`keys: String` test is for specifying a `String` as `keys`. But new assertion is for specifying nothing. `test("no keys")` is a new test name candidate.
##########
ruby/red-arrow/test/test-table.rb:
##########
@@ -1079,15 +1081,16 @@ def setup
table2 = Arrow::Table.new(key1: [1, 2, 2],
key2: [100, 20, 50],
string: ["1-100", "2-20", "2-50"])
- assert_equal(Arrow::Table.new([
- ["key1", [1, 2]],
- ["key2", [100, 20]],
- ["number", [1100, 2020]],
- ["key1", [1, 2]],
- ["key2", [100, 20]],
- ["string", ["1-100", "2-20"]],
- ]),
- table1.join(table2, ["key1", :key2]))
+ expected = Arrow::Table.new([
+ ["key1", [1, 2]],
+ ["key2", [100, 20]],
+ ["number", [1100, 2020]],
+ ["key1", [1, 2]],
+ ["key2", [100, 20]],
+ ["string", ["1-100", "2-20"]],
+ ])
+ assert_equal(expected, table1.join(table2, ["key1", :key2]))
+ assert_equal(expected, table1.join(table2))
Review Comment:
ditto.
--
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