You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "nealrichardson (via GitHub)" <gi...@apache.org> on 2023/04/11 15:05:37 UTC

[GitHub] [arrow] nealrichardson commented on a diff in pull request #35039: GH-35038: [R] argument order in arrow_table affects object return type

nealrichardson commented on code in PR #35039:
URL: https://github.com/apache/arrow/pull/35039#discussion_r1162962088


##########
r/tests/testthat/test-Table.R:
##########
@@ -711,3 +711,20 @@ test_that("as_arrow_table() errors on data.frame with NULL names", {
   names(df) <- NULL
   expect_error(as_arrow_table(df), "Input data frame columns must be named")
 })
+
+test_that("we only preserve metadata of input to arrow_table when passed a single data.frame", {
+  # data.frame in, data.frame out
+  df <- data.frame(x = 1)
+  out1 <- as.data.frame(arrow_table(df))
+  expect_s3_class(out1, "data.frame", exact = TRUE)
+
+  # tibble in, tibble out
+  tib <- tibble::tibble(x = 1)
+  out2 <- as.data.frame(arrow_table(tib))
+  expect_s3_class(out2, c("tbl_df", "tbl", "data.frame"), exact = TRUE)
+
+  # GH-35038 - passing in multiple arguments doesn't affect return type
+  out3 <- as.data.frame(arrow::arrow_table(df, name = "1"))
+  out4 <- as.data.frame(arrow::arrow_table(name = "1", df))

Review Comment:
   ```suggestion
     out3 <- as.data.frame(arrow_table(df, name = "1"))
     out4 <- as.data.frame(arrow_table(name = "1", df))
   ```
   
   Do you also want to assert what the class is, and not just that they're identical?



-- 
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