jonkeane commented on a change in pull request #11956:
URL: https://github.com/apache/arrow/pull/11956#discussion_r794658143
##########
File path: r/tests/testthat/test-Array.R
##########
@@ -572,6 +572,29 @@ test_that("Array$create() handles vector -> list arrays
(ARROW-7662)", {
expect_error(Array$create(list(df)))
})
+test_that("Array$create() handles list of dataframes -> map arrays", {
+ # Should be able to create an empty map with a type hint.
+ expect_r6_class(Array$create(list(), type = map_of(utf8(), boolean())),
"MapArray")
+
+ # MapType is alias for List<Struct<keys, values>>
+ data <- list(data.frame(key = c("a", "b"), value = c(1, 2), stringsAsFactors
= FALSE),
+ data.frame(key = c("a", "c"), value = c(4, 7), stringsAsFactors
= FALSE))
+ arr <- Array$create(data, type = map_of(utf8(), int32()))
+
+ expect_r6_class(arr, "MapArray")
+ expect_as_vector(arr, data, ignore_attr = TRUE)
Review comment:
Aaah yes, of course! Thanks
--
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]