jonkeane commented on a change in pull request #11956:
URL: https://github.com/apache/arrow/pull/11956#discussion_r794551527
##########
File path: r/tests/testthat/test-data-type.R
##########
@@ -367,6 +367,46 @@ test_that("list type works as expected", {
expect_equal(x$value_field, field("item", int32()))
})
+test_that("map type works as expected", {
+ x <- map_of(int32(), utf8())
+ expect_equal(x$id, Type$MAP)
+ expect_equal(x$name, "map")
+ expect_equal(x$ToString(), "map<int32, string>")
+ expect_true(x == x)
+ expect_false(x == null())
+ expect_equal(
+ x$key_field,
+ field("key", int32(), nullable = FALSE)
+ )
+ expect_equal(
+ x$item_field,
+ field("value", utf8())
+ )
+ expect_equal(x$key_type, int32())
+ expect_equal(x$item_type, string())
+ # TODO: (ARROW-15102): Enable constructing StructTypes with non-nullable
fields, so
+ # we can make this comparison:
+ # nolint start (lintr doesn't like commented out code)
+ # expect_equal(x$value_type, struct(key = x$key_field, value = x$item_field))
+ # nolint end
Review comment:
```suggestion
# expect_equal(x$value_type, struct(key = x$key_field, value =
x$item_field)) # nolint
```
You don't have to do it this way (the start/end also works) but this
_should_ work unless lintr's parsing doesn't do the right thing
--
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]