Skip to content

GH-50163: [R] Bug: Partial matching on $metadata$r causes errors with schema metadata keys starting with "r"#50178

Merged
thisisnic merged 3 commits into
apache:mainfrom
thisisnic:GH-50163-partial-matching
Jun 17, 2026
Merged

GH-50163: [R] Bug: Partial matching on $metadata$r causes errors with schema metadata keys starting with "r"#50178
thisisnic merged 3 commits into
apache:mainfrom
thisisnic:GH-50163-partial-matching

Conversation

@thisisnic

@thisisnic thisisnic commented Jun 15, 2026

Copy link
Copy Markdown
Member

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

Copilot AI review requested due to automatic review settings June 15, 2026 14:21
@thisisnic thisisnic requested a review from jonkeane as a code owner June 15, 2026 14:21
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #50163 has been automatically assigned in GitHub to PR creator.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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$r reads/writes with exact-match metadata[["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().

Comment thread r/tests/testthat/test-metadata.R Outdated

@jonkeane jonkeane left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment thread r/R/arrow-tabular.R
} else {
# Set the R metadata
self$metadata$r <- new
self$metadata[["r"]] <- new

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this!

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels Jun 17, 2026
Copilot AI review requested due to automatic review settings June 17, 2026 08:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • r/man/Schema-class.Rd: Generated file

Comment thread r/tests/testthat/test-metadata.R
Comment thread r/extra-tests/test-read-files.R
Comment thread r/R/metadata.R
@thisisnic thisisnic merged commit 1a428c9 into apache:main Jun 17, 2026
16 checks passed
@thisisnic thisisnic removed the awaiting merge Awaiting merge label Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants