GH-39603: [R] Error: Cannot convert Dictionary Array of type dictionary<values=large_string, indices=uint32, ordered=0> to R#49710
Conversation
|
|
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.
| 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) |
| } | ||
| }) | ||
|
|
||
| test_that("Table converts dictionary arrays with wider index types back to R", { |
There was a problem hiding this comment.
with wider index types
I finally got what this was saying, but it took a few clicks. Maybe we say something about uint64 / uint32 here?
| test_that("Table converts dictionary arrays with uint32/int64/uint64 index types back to R", { | ||
| fact <- example_data[, "fct"] | ||
|
|
||
| tab_uint32 <- Table$create(fact, schema = schema(fct = dictionary(uint32(), utf8()))) | ||
| expect_equal(tab_uint32$schema, schema(fct = dictionary(uint32(), utf8()))) |
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit b3ba226. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 43 possible false positives for unstable benchmarks that are known to sometimes produce them. |
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