Skip to content

GH-37761: [R] Argument names ignored in schema supplied as in_type argument to register_scalar_function() - #51324

Merged
thisisnic merged 3 commits into
apache:mainfrom
thisisnic:GH-37762-schema-validation
Sep 18, 2026
Merged

thisisnic merged 3 commits into
apache:mainfrom
thisisnic:GH-37762-schema-validation

Conversation

@thisisnic

@thisisnic thisisnic commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

No validation/warning makes it easy for incorrectly specified UDFs to appear to work...but they don't!

What changes are included in this PR?

Validation

Are these changes tested?

Yeah

Are there any user-facing changes?

I guess if they have incorrectly specified UDFs, yeah

AI usage

All of it, we talked tho

@thisisnic
thisisnic requested a review from jonkeane as a code owner September 13, 2026 16:05
Copilot AI lite review requested due to automatic review settings September 13, 2026 16:05
@github-actions github-actions Bot added the awaiting committer review Awaiting committer review label Sep 13, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #37761 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.

🟡 Changes recommended

Validation still bypasses explicitly declared arguments when a function also includes ....

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds validation to ensure named UDF input schemas match function argument names.

Changes:

  • Implements argument-name validation.
  • Adds regression tests and snapshots.
  • Updates documentation.
File summaries
File Description
r/tests/testthat/test-udf.R Adds validation tests.
r/tests/testthat/_snaps/udf.md Records validation output.
r/R/udf.R Implements argument-name validation.
r/man/register_scalar_function.Rd Documents naming requirements.
Review details

Files not reviewed (1)

  • r/man/register_scalar_function.Rd: Generated file
  • Files reviewed: 3/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread r/R/udf.R Outdated

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.

🔵 Needs a closer look

Two moderate validation gaps remain in r/R/udf.R.

Review details

Files not reviewed (1)

  • r/man/register_scalar_function.Rd: Generated file

Suppressed comments (2)

r/R/udf.R:171

  • When a later kernel has more fields than fun, indexing fun_arg_names past its length yields NA; any() then returns NA and isTRUE() suppresses the mismatch. For example, function(context, x) with list(schema(x = int32()), schema(x = int32(), y = int32())) passes this new name check and produces an invalid arrow_scalar_function; treat named positions beyond fun_arg_names as mismatches (and add a regression test).
        isTRUE(any(nzchar(nms) & nms != fun_arg_names[seq_along(nms)]))

r/R/udf.R:166

  • Because the name check is gated by !fun_formals_have_dots, any function with ... bypasses it—even function(context, x, ...), where x is a fixed positional argument. For example, schema(blah = int32()) is still silently accepted for that function, so the bug this PR targets remains for mixed fixed/ellipsis formals. Restrict the exemption to the ellipsis portion and validate explicit formals before it.
  if (!fun_formals_have_dots) {
    fun_arg_names <- names(formals(fun))[-1]
  • Files reviewed: 3/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 17, 2026 22:47
@thisisnic
thisisnic marked this pull request as draft September 17, 2026 22:48

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.

🟢 Approval recommended

The validation is correctly implemented and documented, and the added tests/snapshots cover the new behavior and expected error messaging.

Review details

Files not reviewed (1)

  • r/man/register_scalar_function.Rd: Generated file
  • Files reviewed: 3/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@thisisnic
thisisnic marked this pull request as ready for review September 18, 2026 00:08

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

Looks good

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels Sep 18, 2026
@thisisnic
thisisnic merged commit c07de67 into apache:main Sep 18, 2026
37 checks passed
@thisisnic thisisnic removed the awaiting merge Awaiting merge label Sep 18, 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