R-JunmingChen commented on code in PR #37418:
URL: https://github.com/apache/arrow/pull/37418#discussion_r1355131941


##########
cpp/src/arrow/array/array_dict_test.cc:
##########
@@ -1428,6 +1428,71 @@ TEST(TestDictionary, IndicesArray) {
   ASSERT_OK(arr->indices()->ValidateFull());
 }
 
+void CheckDictionaryCompact(const std::shared_ptr<DataType>& dict_type,
+                            const std::string& input_dictionary_json,
+                            const std::string& input_index_json,
+                            const std::string& expected_dictionary_json,
+                            const std::string& expected_index_json) {
+  auto input = DictArrayFromJSON(dict_type, input_index_json, 
input_dictionary_json);
+  const DictionaryArray& input_ref = checked_cast<const 
DictionaryArray&>(*input);
+
+  auto expected =
+      DictArrayFromJSON(dict_type, expected_index_json, 
expected_dictionary_json);
+
+  ASSERT_OK_AND_ASSIGN(std::shared_ptr<Array> actual, input_ref.Compact());
+  AssertArraysEqual(*expected, *actual, /*verbose=*/true);
+}
+
+TEST(TestDictionary, Compact) {
+  std::shared_ptr<arrow::DataType> type;
+  std::shared_ptr<arrow::DataType> dict_type;
+
+  for (const auto& index_type : all_dictionary_index_types()) {
+    ARROW_SCOPED_TRACE("index_type = ", index_type->ToString());
+
+    type = boolean();
+    dict_type = dictionary(index_type, type);
+

Review Comment:
   No. We can't create a DictionaryArray with invalid index type.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to