feat(r): Create and modify nanoarrow_schema objects #101
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.
This PR implements "create" and "modify" for
nanoarrow_schema
objects. Before this PR, all type, field, and schemas originated in the Arrow package and were imported via C. This PR doesn't change that, but does implement the ability to do that for the next PR. That infrastructure is rather extensive, since it involves implementingschema$some_field <- some_object
. In R the expectation is "copy on modify", so appropriately this implementation does a deep copy and then sets the field value. I checked to make sure this wouldn't be prohibitively slow and it's not...on my computer modifying a 1-million column struct takes ~0.1s. For Arrays the approach will have to be slightly different because deep copying an Array is more problematic.An interesting problem came up when trying to make sure that
some_struct$children$some_name <- na_int32()
did "the right thing" (I would expect that line to update the type ofsome_name
but not the name of the column). A consequence of that is that doingsome_struct$children$some_name$name <- "a new name"
has no effect, which might be confusing (you'd have to donames(some_struct$children)[1] <- "a new name"
instead).Anyway, after this PR you can create a
struct ArrowSchema
representing any Arrow type and modify all of the fields.