GH-50163: [R] Bug: Partial matching on $metadata$r causes errors with schema metadata keys starting with "r"#50178
Merged
Conversation
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an R-specific bug where accessing x$metadata$r could partially match other schema metadata keys starting with "r" (e.g., "rachel"), leading to spurious "Invalid metadata$r" warnings or errors (GH-50163).
Changes:
- Replaced
$metadata$rreads/writes with exact-matchmetadata[["r"]]in affected R entrypoints (collect/as.data.frame/grouping, schema helpers, feather reading). - Added a regression test ensuring schema metadata keys starting with
"r"don’t trigger R-metadata application. - Minor reordering in
arrowExports.R(no functional change expected).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| r/tests/testthat/test-metadata.R | Adds regression test covering partial-match metadata keys starting with "r". |
| r/R/schema.R | Uses metadata[["r"]] for exact-match R metadata access in schema helpers. |
| r/R/metadata.R | Uses exact-match old_schema$metadata[["r"]] when carrying forward R metadata. |
| r/R/feather.R | Applies R metadata from out$metadata[["r"]] to avoid partial matching. |
| r/R/dplyr-group-by.R | Uses exact-match access for grouped metadata stored under "r". |
| r/R/dplyr-collect.R | Uses exact-match access when applying R metadata during collect. |
| r/R/arrowExports.R | Reorders a couple of exported Field helpers. |
| r/R/arrow-tabular.R | Uses exact-match access for r_metadata and as.data.frame.ArrowTabular(). |
jonkeane
approved these changes
Jun 17, 2026
jonkeane
left a comment
Member
There was a problem hiding this comment.
Thanks for this. I assume that you already greped for $r throughout and caught those, but if you want a second set of eyes, I can pull this branch and do that myself too
| } else { | ||
| # Set the R metadata | ||
| self$metadata$r <- new | ||
| self$metadata[["r"]] <- new |
Member
There was a problem hiding this comment.
I love partial matching so much.
|
|
||
| test_that("metadata keys starting with 'r' don't cause partial matching - GH-50163", { | ||
| tbl <- arrow_table(x = 1:3) | ||
| tbl <- tbl$cast(tbl$schema$WithMetadata(list(rachel = "some_value"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Partial matching meant metadata beginning with R was triggering errors
What changes are included in this PR?
Access fields via
[[not$Are these changes tested?
Yes
Are there any user-facing changes?
No
$metadata$rcauses errors with schema metadata keys starting with "r" #50163