thisisnic commented on a change in pull request #11690:
URL: https://github.com/apache/arrow/pull/11690#discussion_r751997833
##########
File path: r/tests/testthat/test-dplyr-funcs-type.R
##########
@@ -625,3 +625,85 @@ test_that("bad explicit type conversions with as.*()", {
)
)
})
+
+test_that("structs/nested data frames/tibbles can be created", {
+ df <- tibble(regular_col1 = 1L, regular_col2 = "a")
+
+ compare_dplyr_binding(
+ .input %>%
+ transmute(
+ df_col = tibble(
+ regular_col1 = regular_col1,
+ regular_col2 = regular_col2
+ )
+ ) %>%
+ collect(),
+ df
+ )
+
+ # check auto column naming
+ compare_dplyr_binding(
+ .input %>%
+ transmute(
+ df_col = tibble(regular_col1, regular_col2)
+ ) %>%
+ collect(),
+ df
+ )
+
+ # ...and that other arguments are not supported
+ expect_warning(
+ RecordBatch$create(char_col = "a") %>%
+ mutate(df_col = tibble(char_col, .rows = 1L)),
+ ".rows not supported in Arrow"
+ )
+
+ expect_warning(
+ RecordBatch$create(char_col = "a") %>%
+ mutate(df_col = tibble(char_col, .name_repair = "universal")),
+ ".name_repair not supported in Arrow"
+ )
+
+ # check that data.frame is mapped too
+ # stringsAsFactors default is TRUE in R 3.6, which is still tested on CI
+ compare_dplyr_binding(
+ .input %>%
+ transmute(
+ df_col = data.frame(regular_col1, regular_col2, stringsAsFactors =
FALSE)
+ ) %>%
+ collect() %>%
+ mutate(df_col = as.data.frame(df_col)),
+ df
+ )
+
+ # ...and that other arguments are not supported
+ expect_warning(
+ RecordBatch$create(char_col = "a") %>%
+ mutate(df_col = data.frame(char_col, stringsAsFactors = TRUE)),
+ "stringsAsFactors = TRUE not supported in Arrow"
+ )
+
+ expect_warning(
+ RecordBatch$create(char_col = "a") %>%
+ mutate(df_col = data.frame(char_col, row.names = 1L)),
+ "row.names not supported in Arrow"
+ )
+
+ expect_warning(
+ RecordBatch$create(char_col = "a") %>%
+ mutate(df_col = data.frame(char_col, check.rows = TRUE)),
+ "check.rows not supported in Arrow"
+ )
+
+ expect_warning(
+ RecordBatch$create(char_col = "a") %>%
+ mutate(df_col = data.frame(char_col, check.names = 1L)),
+ "check.names not supported in Arrow"
+ )
+
+ expect_warning(
+ RecordBatch$create(char_col = "a") %>%
+ mutate(df_col = data.frame(char_col, fix.empty.names = 1L)),
+ "fix.empty.names not supported in Arrow"
+ )
Review comment:
Super minor nit about something which isn't currently done consistently
anyway, so feel free to disregard, but I reckon using the alias makes it more
skimmable.
```suggestion
expect_warning(
record_batch(char_col = "a") %>%
mutate(df_col = tibble(char_col, .rows = 1L)),
".rows not supported in Arrow"
)
expect_warning(
record_batch(char_col = "a") %>%
mutate(df_col = tibble(char_col, .name_repair = "universal")),
".name_repair not supported in Arrow"
)
# check that data.frame is mapped too
# stringsAsFactors default is TRUE in R 3.6, which is still tested on CI
compare_dplyr_binding(
.input %>%
transmute(
df_col = data.frame(regular_col1, regular_col2, stringsAsFactors =
FALSE)
) %>%
collect() %>%
mutate(df_col = as.data.frame(df_col)),
df
)
# ...and that other arguments are not supported
expect_warning(
record_batch(char_col = "a") %>%
mutate(df_col = data.frame(char_col, stringsAsFactors = TRUE)),
"stringsAsFactors = TRUE not supported in Arrow"
)
expect_warning(
record_batch(char_col = "a") %>%
mutate(df_col = data.frame(char_col, row.names = 1L)),
"row.names not supported in Arrow"
)
expect_warning(
record_batch(char_col = "a") %>%
mutate(df_col = data.frame(char_col, check.rows = TRUE)),
"check.rows not supported in Arrow"
)
expect_warning(
record_batch(char_col = "a") %>%
mutate(df_col = data.frame(char_col, check.names = 1L)),
"check.names not supported in Arrow"
)
expect_warning(
record_batch(char_col = "a") %>%
mutate(df_col = data.frame(char_col, fix.empty.names = 1L)),
"fix.empty.names not supported in Arrow"
)
```
--
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]