Skip to content

GH-49836: [R] Reject unrepresentable Date values before converting to Arrow - #55823

Closed
mrbuho-O wants to merge 1 commit into
apache:mainfrom
mrbuho-O:fix-r-nonfinite-date-49836
Closed

mrbuho-O wants to merge 1 commit into
apache:mainfrom
mrbuho-O:fix-r-nonfinite-date-49836

Conversation

@mrbuho-O

Copy link
Copy Markdown

Rationale for this change

An R Date can contain infinity or NaN. On Windows with Arrow 26.0.1.1, converting any of those values to a table, or writing and reading it through Feather or Parquet, produced a date 2,147,483,648 days before the epoch. A date comparison can then return the wrong answer.

What changes are included in this PR?

Check that the day or millisecond count fits the signed storage type before casting it. R's NA still produces an Arrow null. NaN, either infinity and finite dates outside the storage range raise a conversion error. This preserves the R binding's distinction between NA and NaN.

Are these changes tested?

Yes. The regression covers both Arrow date types, ordinary dates on either side of the epoch, missing dates, NaN, both infinities and storage limits. I built the patched R package on Windows with R 4.6.2. The Array test file passed 1,189 expectations with 10 skips. I also verified the table, Feather V2 and Parquet examples before and after the change.

Are there any user-facing changes?

This PR contains a Critical Fix. Previously, converting an unrepresentable R date could write a finite date into the output. Conversion now reports the value and target type.

Was AI used for this PR?

OpenAI Codex wrote the code, regression tests and PR description. Codex also reviewed the change and ran the tests.

PR code and description written by

  • Human
  • AI

Reviewed before submission by

  • Human
  • AI
  • Not reviewed

Closes #49836.

@thisisnic

Copy link
Copy Markdown
Member

Closing this PR as it doesn't meet our guidelines on AI-generated contributions:

https://arrow.apache.org/docs/developers/overview.html#ai-generated-code

If you'd like to contribute this change, please review and test the code yourself, then open a new PR.

@thisisnic thisisnic closed this Nov 27, 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.

[R] Date Inf/ -Inf silently corrupted when converting to Arrow date32

2 participants