Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion r/R/dataset-write.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,13 @@ write_dataset <- function(dataset,
validate_positive_int_value(min_rows_per_group)
validate_positive_int_value(max_rows_per_group)

source_schema <- source_data(dataset)$schema
# For backwards compatibility with Scanner-based writer (arrow <= 7.0.0):
# retain metadata from source dataset
Comment on lines +210 to +211
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we had one already, a jira would be nice here, but I'm sure we'll remember this is where it's going even without it, so let'snot

output_schema$metadata <- source_schema$metadata
new_r_meta <- get_r_metadata_from_old_schema(
output_schema,
source_data(dataset)$schema,
source_schema,
drop_attributes = has_aggregation(dataset)
)
if (!is.null(new_r_meta)) {
Expand Down
10 changes: 8 additions & 2 deletions r/tests/testthat/test-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ test_that("RecordBatch metadata", {
})

test_that("RecordBatch R metadata", {

expect_identical(as.data.frame(record_batch(example_with_metadata)), example_with_metadata)
})

Expand Down Expand Up @@ -306,7 +305,11 @@ test_that("Dataset writing does handle other metadata", {
skip_if_not_available("parquet")

dst_dir <- make_temp_dir()
write_dataset(example_with_metadata, dst_dir, partitioning = "b")
tab <- Table$create(example_with_metadata)
# Tack on extra non-R metadata: sfarrow 0.4.1 relies on this
tab$metadata[["other_stuff"]] <- "hello"

write_dataset(tab, dst_dir, partitioning = "b")

ds <- open_dataset(dst_dir)
expect_equal(
Expand All @@ -316,6 +319,9 @@ test_that("Dataset writing does handle other metadata", {
collect(),
example_with_metadata
)

# Check for that extra metadata in the schema:
expect_equal(ds$metadata$other_stuff, "hello")
})

test_that("dplyr with metadata", {
Expand Down