Skip to content

fix(r): Convert I()-wrapped vectors without arrow installed - #954

Merged
paleolimbot merged 2 commits into
apache:mainfrom
nbenn:953-asis-array
Sep 29, 2026
Merged

paleolimbot merged 2 commits into
apache:mainfrom
nbenn:953-asis-array

Conversation

@nbenn

@nbenn nbenn commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add an as_nanoarrow_array() method for AsIs that strips the class and dispatches again, mirroring the infer_nanoarrow_schema() method. An I()-wrapped base vector, such as a list column kept whole in a data.frame(), no longer falls through to the arrow fallback.
  • The method does not forward ...: when the C conversion calls back for a data frame column, ... carries .from_c = TRUE, which would still route the unwrapped value to arrow.
  • Both AsIs methods, including the existing schema one, remove only the AsIs class, as base R's print.AsIs() does. Removing the first class instead is the same for anything I() returns, but otherwise drops whatever class comes ahead of AsIs, so a c("Date", "AsIs") value reaching the array method through NextMethod() would be converted to int32 as its day count.
  • Values whose class has its own method, such as I(as.Date(...)) or an I()-wrapped blob, convert as before, with or without arrow. An I()-wrapped matrix, which failed even with arrow installed, and an I()-wrapped integer64 with missing values, which needed arrow, now convert too.
  • The array test sets the nanoarrow.without_arrow option, so it fails on main even where arrow is installed, as it is in CI.

Fixes #953

The schema side already strips the `AsIs` class and dispatches again,
but `as_nanoarrow_array()` had no counterpart, so an `I()`-wrapped base
vector fell through to the default method's arrow fallback. The new
method does not forward `...`, which can carry `.from_c = TRUE` and
would still route the unwrapped value to arrow.
Removing the first class assumes `AsIs` leads the class vector. That
holds for `I()`, but when another class comes first it was dropped
instead: a Date reaching the array method through `NextMethod()` with an
int32 schema was converted as its number of days. Strip exactly `AsIs`,
as base R's `print.AsIs()` and vctrs' `asis_strip()` do.
@nbenn
nbenn marked this pull request as ready for review September 28, 2026 16:18
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.20%. Comparing base (8f81815) to head (ad41f6c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #954   +/-   ##
=======================================
  Coverage   78.19%   78.20%           
=======================================
  Files         106      106           
  Lines       16845    16847    +2     
  Branches     1985     1985           
=======================================
+ Hits        13172    13175    +3     
+ Misses       2439     2438    -1     
  Partials     1234     1234           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Thank you!

@paleolimbot
paleolimbot merged commit ef5cd2f into apache:main Sep 29, 2026
12 checks passed
@nbenn
nbenn deleted the 953-asis-array branch September 29, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The R package needs arrow to convert I()-wrapped vectors

3 participants