You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/30 13:15:47 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #13334: ARROW-14314: [C++] Sorting dictionary array not implemented

pitrou commented on code in PR #13334:
URL: https://github.com/apache/arrow/pull/13334#discussion_r911013587


##########
cpp/src/arrow/compute/kernels/vector_sort_test.cc:
##########
@@ -352,6 +352,17 @@ TEST(ArraySortIndicesFunction, Array) {
   expected = ArrayFromJSON(uint64(), "[2, 4, 6, 1, 0, 3, 5]");
   ASSERT_OK_AND_ASSIGN(actual, CallFunction("array_sort_indices", {arr}, &options));
   AssertDatumsEqual(expected, actual, /*verbose=*/true);
+
+  // Dictionary Array
+  auto dict_arr = DictArrayFromJSON(dictionary(uint64(), utf8()), "[0, null, 1, 0, 2, 3]",
+                                    "[ \"b\", null, \"c\", \"a\"]");
+  expected = ArrayFromJSON(uint64(), "[5, 0, 3, 4, 1, 2]");
+  ASSERT_OK_AND_ASSIGN(actual, CallFunction("array_sort_indices", {dict_arr}));
+  AssertDatumsEqual(expected, actual, /*verbose=*/true);
+
+  expected = ArrayFromJSON(uint64(), "[1, 2, 4, 0, 3, 5]");
+  ASSERT_OK_AND_ASSIGN(actual, CallFunction("array_sort_indices", {dict_arr}, &options));
+  AssertDatumsEqual(expected, actual, /*verbose=*/true);

Review Comment:
   ```suggestion
   }
   
   TEST(ArraySortIndicesFunction, DictionaryArray) {
     // Dictionary Array (["b", null, null, null, "b", "c", "a"])
     auto dict_arr =
         DictArrayFromJSON(dictionary(uint64(), utf8()), "[0, null, 1, null, 0, 2, 3]",
                           "[ \"b\", null, \"c\", \"a\"]");
     auto expected = ArrayFromJSON(uint64(), "[6, 0, 4, 5, 1, 2, 3]");
     ASSERT_OK_AND_ASSIGN(auto actual, CallFunction("array_sort_indices", {dict_arr}));
     AssertDatumsEqual(expected, actual, /*verbose=*/true);
   
     ArraySortOptions options{SortOrder::Ascending, NullPlacement::AtStart};
     expected = ArrayFromJSON(uint64(), "[1, 2, 3, 6, 0, 4, 5]");
     ASSERT_OK_AND_ASSIGN(actual, CallFunction("array_sort_indices", {dict_arr}, &options));
     AssertDatumsEqual(expected, actual, /*verbose=*/true);
   
     options.order = SortOrder::Descending;
     expected = ArrayFromJSON(uint64(), "[1, 2, 3, 5, 0, 4, 6]");
     ASSERT_OK_AND_ASSIGN(actual, CallFunction("array_sort_indices", {dict_arr}, &options));
     AssertDatumsEqual(expected, actual, /*verbose=*/true);
   
     options.null_placement = NullPlacement::AtEnd;
     expected = ArrayFromJSON(uint64(), "[5, 0, 4, 6, 1, 2, 3]");
     ASSERT_OK_AND_ASSIGN(actual, CallFunction("array_sort_indices", {dict_arr}, &options));
     AssertDatumsEqual(expected, actual, /*verbose=*/true);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org