andishgar opened a new issue, #54026:
URL: https://github.com/apache/arrow/issues/54026
### Describe the bug, including details regarding any error messages,
version, and platform.
The following test demonstrates that comparing a sliced `DictionaryArray`
with another `DictionaryArray` returns `false`, even though both arrays have
the same logical values.
```cpp
TEST(MyTest, Test) {
auto dict_type = dictionary(int32(), int32());
std::vector<int> a1_values(3);
std::vector<int> a1_indices(3);
for (int i = 0; i < 3; i++) {
a1_values[i] = i + 97;
a1_indices[i] = i;
}
std::vector<int> a2_vector_values(100);
std::iota(a2_vector_values.begin(), a2_vector_values.end(), 0);
std::shared_ptr<Array> a1_array_values;
std::shared_ptr<Array> a1_array_indices;
std::shared_ptr<Array> a2_array_values;
ArrayFromVector<Int32Type>(a1_values, &a1_array_values);
ArrayFromVector<Int32Type>(a1_indices, &a1_array_indices);
ArrayFromVector<Int32Type>(a2_vector_values, &a2_array_values);
auto a1 = std::make_shared<DictionaryArray>(
dict_type, a1_array_indices, a1_array_values);
DictionaryArray a2(dict_type, a2_array_values, a2_array_values);
ASSERT_OK(a1->ValidateFull());
ASSERT_OK(a2.ValidateFull());
auto a2_slice = a2.SliceSafe(97, 3).ValueOrDie();
// Both arrays have the same logical values, but Equals returns false.
ASSERT_FALSE(a2_slice->Equals(a1));
// Decoding both arrays confirms that their logical values are equal.
auto decoded_1 =
arrow::compute::CallFunction("dictionary_decode", {a1}).ValueOrDie();
auto decoded_2 =
arrow::compute::CallFunction("dictionary_decode",
{a2_slice}).ValueOrDie();
auto a1_result = decoded_1.array_as<Int32Array>();
auto a2_result = decoded_2.array_as<Int32Array>();
ASSERT_TRUE(a1_result->Equals(*a2_result));
}
```
### Component(s)
C++
--
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]