Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cpp/src/arrow/compute/kernels/vector_array_sort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ class ArrayCompareSorter<DictionaryType> {
RankOptions rank_options(SortOrder::Ascending, NullPlacement::AtEnd,
RankOptions::Dense);

// XXX Should this support Type::NA?
auto data = array->data();
std::shared_ptr<Buffer> null_bitmap;
if (array->null_count() > 0) {
Expand Down
21 changes: 21 additions & 0 deletions cpp/src/arrow/compute/kernels/vector_sort_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,27 @@ TEST(ArraySortIndicesFunction, AllNullDictionaryArray) {
}
}

TEST(ArraySortIndicesFunction, NullTypeDictionaryArray) {
// Test that dictionaries with Type::NA (null type) values can be sorted.
// All values in a null-type dictionary are logically null, so sorting
// should just arrange indices based on null placement, preserving order.
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]", "[]");

for (auto null_placement : AllNullPlacements()) {
ArraySortOptions options{SortOrder::Ascending, null_placement};
// All nulls, so output should be identity permutation
auto expected = ArrayFromJSON(uint64(), "[0, 1, 2, 3]");
ASSERT_OK_AND_ASSIGN(auto actual,
CallFunction("array_sort_indices", {dict_arr}, &options));
ValidateOutput(actual);
AssertDatumsEqual(expected, actual, /*verbose=*/true);
}
}
}

Result<std::shared_ptr<Array>> DecodeDictionary(const Array& array) {
const auto& dict_array = checked_cast<const DictionaryArray&>(array);
ARROW_ASSIGN_OR_RAISE(auto decoded_datum,
Expand Down
Loading