-
Notifications
You must be signed in to change notification settings - Fork 4k
GH-48954: [C++] Add test for null-type dictionary sorting and clarify XXX comment #48955
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
base: main
Are you sure you want to change the base?
Conversation
|
|
be21f43 to
492085d
Compare
raulcd
left a comment
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.
I understand we add a test to validate it doesn't blow up or produce garbage even though there's no usefulness to it, right?
I was just trying to understand what does that even mean (the null-type dictionary sorting case).
|
Ah yeah. If I am correct, this behaviour is not being specifically tested. Yes. so I am removing the question, and adding a regression test. The nullability comparison/behaviour from: pc.array_sort_indices(pa.array([None, None, None, None], type=pa.int8()))is already consistent with: pc.array_sort_indices(pa.DictionaryArray.from_arrays(
indices=pa.array([None, None, None, None], type=pa.int8()),
dictionary=pa.array([], type=pa.null())
))so I believe we don't necessarily have to change. I am happy to remove the test or do something else if you have other preferences! |
raulcd
left a comment
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.
LGTM
| for (const auto& index_type : all_dictionary_index_types()) { | ||
| ARROW_SCOPED_TRACE("index_type = ", index_type->ToString()); | ||
| auto dict_type = dictionary(index_type, null()); | ||
| auto dict_arr = DictArrayFromJSON(dict_type, "[null, null, null, null]", "[]"); |
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.
Hmm, another way of encoding this is to have null values in the dictionary, perhaps test that too?
For example:
| auto dict_arr = DictArrayFromJSON(dict_type, "[null, null, null, null]", "[]"); | |
| auto dict_arr = DictArrayFromJSON(dict_type, "[null, 0, 0, null]", "[null]"); |
Rationale for this change
Null-type dictionaries (e.g.,
dictionary(int8(), null())) are valid Arrow constructs supported from day one, but the sorting code had an uncertainXXX Should this support Type::NA?comment. We should explicitly support and test this because other functions already support this:I believe it does not make sense to specifically disallow this in dictionaries at this point.
What changes are included in this PR?
Added a unittest for null sorting behaviour.
Are these changes tested?
Yes, the unittest was added.
Are there any user-facing changes?
No.