jonkeane commented on code in PR #48104:
URL: https://github.com/apache/arrow/pull/48104#discussion_r2523797720


##########
r/tests/testthat/test-metadata.R:
##########
@@ -490,3 +490,30 @@ test_that("data.frame class attribute is not saved", {
   df_arrow <- arrow_table(df)
   expect_identical(df_arrow$r_metadata, list(attributes = list(foo = "bar"), 
columns = list(x = NULL)))
 })
+
+test_that("apply_arrow_r_metadata doesn't add in metadata from plain 
data.frame objects", {
+  # with just a plain df the (empty) column metadata is not preserved
+  plain_df <- data.frame(x = 1:5)
+  plain_df_arrow <- arrow_table(plain_df)
+
+  expect_equal(plain_df_arrow$metadata$r$columns, list(x = NULL))
+
+  plain_df_no_metadata <- plain_df_arrow$to_data_frame()
+  plain_df_with_metadata <- apply_arrow_r_metadata(plain_df_no_metadata, 
plain_df_arrow$metadata$r)
+
+  expect_identical(df_no_metadata, df_with_metadata)
+
+  # with more complex column metadata - it preserves it
+  spicy_df_arrow <- arrow_table(haven_data)

Review Comment:
   🌶️ 



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

Reply via email to