lidavidm commented on a change in pull request #11370:
URL: https://github.com/apache/arrow/pull/11370#discussion_r727424188
##########
File path: cpp/src/arrow/compute/kernels/aggregate_test.cc
##########
@@ -2265,6 +2264,53 @@ TYPED_TEST(TestStringIndexKernel, Basics) {
this->AssertIndexIs(R"(["foo", null, null])", null_value, -1);
}
+TEST(TestIndexKernel, FixedSizeBinary) {
+ auto ty = fixed_size_binary(3);
+ auto buffer = Buffer::FromString("foo");
+ auto value = std::make_shared<FixedSizeBinaryScalar>(buffer, ty);
+ auto null_value = std::make_shared<FixedSizeBinaryScalar>(buffer, ty);
+ null_value->is_valid = false;
+
+ CheckIndex(ArrayFromJSON(ty, R"([])"), value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"(["foo"])"), value, 0);
+ CheckIndex(ArrayFromJSON(ty, R"(["bar", "bar", "bar", "bar"])"), value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"(["bar", "bar", "bar", "bar", "foo"])"),
value, 4);
+ CheckIndex(ArrayFromJSON(ty, R"([null, null, null])"), value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"([null, null, null])"), null_value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"(["foo", null, null])"), null_value, -1);
+}
+
+TEST(TestIndexKernel, Decimal) {
+ for (const auto& ty : {decimal128(3, 2), decimal256(3, 2)}) {
+ std::shared_ptr<Scalar> value, null_value;
+ if (ty->id() == Type::DECIMAL128) {
+ value = std::make_shared<Decimal128Scalar>(Decimal128(123), ty);
+ null_value = std::make_shared<Decimal128Scalar>(ty);
+ } else {
+ value = std::make_shared<Decimal256Scalar>(Decimal256(123), ty);
+ null_value = std::make_shared<Decimal256Scalar>(ty);
+ }
+
+ CheckIndex(ArrayFromJSON(ty, R"([])"), value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"(["1.23"])"), value, 0);
+ CheckIndex(ArrayFromJSON(ty, R"(["9.99", "9.99", "9.99", "9.99"])"),
value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"(["9.99", "9.99", "9.99", "9.99",
"1.23"])"), value,
+ 4);
+ CheckIndex(ArrayFromJSON(ty, R"([null, null, null])"), value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"([null, null, null])"), null_value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"(["1.23", null, null])"), null_value, -1);
+ }
+}
+
+TEST(TestIndexKernel, Null) {
+ auto ty = null();
+ auto value = std::make_shared<NullScalar>();
+
+ CheckIndex(ArrayFromJSON(ty, R"([])"), value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"([null])"), value, -1);
+ CheckIndex(ArrayFromJSON(ty, R"([null, null, null, null])"), value, -1);
+}
+
Review comment:
Hmm, it doesn't seem to be checked anywhere. I'll fix this when I get a
chance.
--
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]