GH-39603: [R] Error: Cannot convert Dictionary Array of type dictionary<values=large_string, indices=uint32, ordered=0> to R#49710
Open
thisisnic wants to merge 1 commit into
Conversation
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes #39603 by extending the non-ALTREP Converter_Dictionary path in the R bindings to support UINT32, INT64, and UINT64 dictionary index types, in addition to adding a safety check for dictionaries larger than R's 32-bit factor code range.
Changes:
- Allow
UINT32/INT64/UINT64index types inConverter_Dictionary's constructor andIngest_some_nullsdispatch. - Add a runtime check that errors when the dictionary length exceeds
std::numeric_limits<int>::max()(R factor code limit). - Add a new test that round-trips a factor through
Table$create()withuint32/int64/uint64dictionary index types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| r/src/array_to_vector.cpp | Adds UINT32/INT64/UINT64 cases to dictionary index handling and adds a dictionary-length overflow guard. |
| r/tests/testthat/test-Table.R | Adds a test round-tripping a factor with wider dictionary index types back to R. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+377
to
+387
| tab_uint32 <- Table$create(fact, schema = schema(fct = dictionary(uint32(), utf8()))) | ||
| expect_equal(tab_uint32$schema, schema(fct = dictionary(uint32(), utf8()))) | ||
| expect_equal_data_frame(tab_uint32, fact) | ||
|
|
||
| tab_int64 <- Table$create(fact, schema = schema(fct = dictionary(int64(), utf8()))) | ||
| expect_equal(tab_int64$schema, schema(fct = dictionary(int64(), utf8()))) | ||
| expect_equal_data_frame(tab_int64, fact) | ||
|
|
||
| tab_uint64 <- Table$create(fact, schema = schema(fct = dictionary(uint64(), utf8()))) | ||
| expect_equal(tab_uint64$schema, schema(fct = dictionary(uint64(), utf8()))) | ||
| expect_equal_data_frame(tab_uint64, fact) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale for this change
Dictionary Arrays with specific type indices caused error
What changes are included in this PR?
Allows those type indices and add check to ensure no overflow
Are these changes tested?
Yes
Are there any user-facing changes?
No
AI Usage
I used AI to create the changes but manually reviewed myself afterwards
dictionary<values=large_string, indices=uint32, ordered=0>to R #39603