-
Notifications
You must be signed in to change notification settings - Fork 4.2k
GH-49689: [R][C++] Parquets do not support list-columns of ordered factors (ordered dictionaries) #49937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
GH-49689: [R][C++] Parquets do not support list-columns of ordered factors (ordered dictionaries) #49937
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6ff3cc8
Add tests for ordered dictionaries
thisisnic fe18d93
Fix failing tests to fail properly
thisisnic 8583075
Plumb in changes needed for ordered dictionaries
thisisnic 1e85543
Fix dangling reference
thisisnic 78bbeef
fix tests
thisisnic 29dfbc7
Changes from PR feedback
thisisnic ac3db34
Update cpp/src/arrow/array/array_dict_test.cc
thisisnic c8ac6ef
Update to use Result returning variants
thisisnic 09429c4
fix missing var
thisisnic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,17 +168,21 @@ struct DictionaryBuilderCase { | |
| template <typename ValueType> | ||
| Status CreateFor() { | ||
| using AdaptiveBuilderType = DictionaryBuilder<ValueType>; | ||
| using ExactBuilderType = | ||
| internal::DictionaryBuilderBase<TypeErasedIntBuilder, ValueType>; | ||
| if (dictionary != nullptr) { | ||
| out->reset(new AdaptiveBuilderType(dictionary, pool)); | ||
| out->reset( | ||
| new AdaptiveBuilderType(dictionary, pool, kDefaultBufferAlignment, ordered)); | ||
| } else if (exact_index_type) { | ||
| if (!is_integer(index_type->id())) { | ||
| return Status::TypeError("MakeBuilder: invalid index type ", *index_type); | ||
| } | ||
| out->reset(new internal::DictionaryBuilderBase<TypeErasedIntBuilder, ValueType>( | ||
| index_type, value_type, pool)); | ||
| out->reset(new ExactBuilderType(index_type, value_type, pool, | ||
| kDefaultBufferAlignment, ordered)); | ||
| } else { | ||
| auto start_int_size = index_type->byte_width(); | ||
| out->reset(new AdaptiveBuilderType(start_int_size, value_type, pool)); | ||
| out->reset(new AdaptiveBuilderType(start_int_size, value_type, pool, | ||
| kDefaultBufferAlignment, ordered)); | ||
| } | ||
| return Status::OK(); | ||
| } | ||
|
|
@@ -188,8 +192,9 @@ struct DictionaryBuilderCase { | |
| MemoryPool* pool; | ||
| const std::shared_ptr<DataType>& index_type; | ||
| const std::shared_ptr<DataType>& value_type; | ||
| const std::shared_ptr<Array>& dictionary; | ||
| std::shared_ptr<Array> dictionary; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was updated as without it, we ended up with a dangling reference when |
||
| bool exact_index_type; | ||
| bool ordered; | ||
| std::unique_ptr<ArrayBuilder>* out; | ||
| }; | ||
|
|
||
|
|
@@ -206,6 +211,7 @@ struct MakeBuilderImpl { | |
| dict_type.value_type(), | ||
| /*dictionary=*/nullptr, | ||
| exact_index_type, | ||
| dict_type.ordered(), | ||
| &out}; | ||
| return visitor.Make(); | ||
| } | ||
|
|
@@ -332,9 +338,13 @@ Status MakeDictionaryBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& | |
| const std::shared_ptr<Array>& dictionary, | ||
| std::unique_ptr<ArrayBuilder>* out) { | ||
| const auto& dict_type = static_cast<const DictionaryType&>(*type); | ||
| DictionaryBuilderCase visitor = { | ||
| pool, dict_type.index_type(), dict_type.value_type(), | ||
| dictionary, /*exact_index_type=*/false, out}; | ||
| DictionaryBuilderCase visitor = {pool, | ||
| dict_type.index_type(), | ||
| dict_type.value_type(), | ||
| dictionary, | ||
| /*exact_index_type=*/false, | ||
| dict_type.ordered(), | ||
| out}; | ||
| return visitor.Make(); | ||
| } | ||
|
|
||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all AI-generated. I roughly understood what it does but am not confident in it, other than having checked it looks relatively idiomatic, and all of these tests except
UnorderedTypeStaysUnorderedfailed before the PR and passed after.