lidavidm commented on a change in pull request #10928:
URL: https://github.com/apache/arrow/pull/10928#discussion_r689584773
##########
File path: cpp/src/arrow/compute/kernels/aggregate_test.cc
##########
@@ -1028,6 +1027,74 @@ TYPED_TEST(TestFloatingMinMaxKernel, DefaultOptions) {
AssertDatumsEqual(explicit_defaults, no_options_provided);
}
+TEST(TestDecimalMinMaxKernel, Decimals) {
+ for (const auto& item_ty : {decimal128(5, 2), decimal256(5, 2)}) {
+ auto ty = struct_({field("min", item_ty), field("max", item_ty)});
+
+ Datum chunked_input1 =
+ ChunkedArrayFromJSON(item_ty, {R"(["5.10", "1.23", "2.00", "3.45",
"4.56"])",
+ R"(["9.42", "1.01", null, "3.14",
"4.00"])"});
+ Datum chunked_input2 =
+ ChunkedArrayFromJSON(item_ty, {R"(["5.10", null, "2.00", "3.45",
"4.56"])",
+ R"(["9.42", "1.01", "2.52", "3.14",
"4.00"])"});
+ Datum chunked_input3 =
+ ChunkedArrayFromJSON(item_ty, {R"(["5.10", "1.23", "2.00", "3.45",
null])",
+ R"(["9.42", "1.01", null, "3.14",
"4.00"])"});
+
+ ScalarAggregateOptions options;
+
+ EXPECT_THAT(
+ MinMax(ArrayFromJSON(item_ty, R"(["5.10", "1.23", "2.00", "3.45",
"4.56"])"),
+ options),
+ ResultWith(ScalarFromJSON(ty, R"({"min": "1.23", "max": "5.10"})")));
+ EXPECT_THAT(
+ MinMax(ArrayFromJSON(item_ty, R"(["5.10", null, "2.00", "3.45",
"4.56"])"),
+ options),
+ ResultWith(ScalarFromJSON(ty, R"({"min": "2.00", "max": "5.10"})")));
Review comment:
Added some negative cases here.
##########
File path: cpp/src/arrow/compute/kernels/hash_aggregate_test.cc
##########
@@ -1013,6 +1013,74 @@ TEST(GroupBy, MinMaxOnly) {
}
}
+TEST(GroupBy, MinMaxDecimal) {
+ auto in_schema = schema({
+ field("argument0", decimal128(3, 2)),
+ field("argument1", decimal256(3, 2)),
+ field("key", int64()),
+ });
+ // for (bool use_exec_plan : {false, true}) {
+ // for (bool use_threads : {true, false}) {
Review comment:
My bad, I forgot to re-enable this.
##########
File path: cpp/src/arrow/compute/kernels/aggregate_basic_internal.h
##########
@@ -228,6 +233,35 @@ struct MinMaxState<ArrowType, SimdLevel,
enable_if_floating_point<ArrowType>> {
bool has_values = false;
};
+template <typename ArrowType, SimdLevel::type SimdLevel>
+struct MinMaxState<ArrowType, SimdLevel, enable_if_decimal<ArrowType>> {
+ using ThisType = MinMaxState<ArrowType, SimdLevel>;
+ using T = typename std::conditional<is_decimal128_type<ArrowType>::value,
Decimal128,
+ Decimal256>::type;
Review comment:
TypeTraits<Decimal128>::CType is already defined, so I changed to use
that.
--
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]