rtpsw commented on code in PR #34311: URL: https://github.com/apache/arrow/pull/34311#discussion_r1125605663
########## cpp/src/arrow/compute/kernels/hash_aggregate_test.cc: ########## @@ -301,53 +426,143 @@ Result<Datum> GroupByTest(const std::vector<Datum>& arguments, {t_agg.function, t_agg.options, "agg_" + ToChars(idx), t_agg.function}); idx = idx + 1; } - return RunGroupBy(arguments, keys, internal_aggregates, use_threads); + return group_by(arguments, keys, segment_keys, internal_aggregates, use_threads, + /*naive=*/false); } -} // namespace +Result<Datum> GroupByTest(GroupByFunction group_by, const std::vector<Datum>& arguments, + const std::vector<Datum>& keys, + const std::vector<TestAggregate>& aggregates, + bool use_threads) { + return GroupByTest(group_by, arguments, keys, {}, aggregates, use_threads); +} -TEST(Grouper, SupportedKeys) { - ASSERT_OK(Grouper::Make({boolean()})); +template <typename GroupClass> +void TestGroupClassSupportedKeys() { + ASSERT_OK(GroupClass::Make({boolean()})); - ASSERT_OK(Grouper::Make({int8(), uint16(), int32(), uint64()})); + ASSERT_OK(GroupClass::Make({int8(), uint16(), int32(), uint64()})); - ASSERT_OK(Grouper::Make({dictionary(int64(), utf8())})); + ASSERT_OK(GroupClass::Make({dictionary(int64(), utf8())})); - ASSERT_OK(Grouper::Make({float16(), float32(), float64()})); + ASSERT_OK(GroupClass::Make({float16(), float32(), float64()})); - ASSERT_OK(Grouper::Make({utf8(), binary(), large_utf8(), large_binary()})); + ASSERT_OK(GroupClass::Make({utf8(), binary(), large_utf8(), large_binary()})); - ASSERT_OK(Grouper::Make({fixed_size_binary(16), fixed_size_binary(32)})); + ASSERT_OK(GroupClass::Make({fixed_size_binary(16), fixed_size_binary(32)})); - ASSERT_OK(Grouper::Make({decimal128(32, 10), decimal256(76, 20)})); + ASSERT_OK(GroupClass::Make({decimal128(32, 10), decimal256(76, 20)})); - ASSERT_OK(Grouper::Make({date32(), date64()})); + ASSERT_OK(GroupClass::Make({date32(), date64()})); for (auto unit : { TimeUnit::SECOND, TimeUnit::MILLI, TimeUnit::MICRO, TimeUnit::NANO, }) { - ASSERT_OK(Grouper::Make({timestamp(unit), duration(unit)})); + ASSERT_OK(GroupClass::Make({timestamp(unit), duration(unit)})); } - ASSERT_OK( - Grouper::Make({day_time_interval(), month_interval(), month_day_nano_interval()})); + ASSERT_OK(GroupClass::Make( + {day_time_interval(), month_interval(), month_day_nano_interval()})); + + ASSERT_OK(GroupClass::Make({null()})); + + ASSERT_RAISES(NotImplemented, GroupClass::Make({struct_({field("", int64())})})); + + ASSERT_RAISES(NotImplemented, GroupClass::Make({struct_({})})); - ASSERT_OK(Grouper::Make({null()})); + ASSERT_RAISES(NotImplemented, GroupClass::Make({list(int32())})); - ASSERT_RAISES(NotImplemented, Grouper::Make({struct_({field("", int64())})})); + ASSERT_RAISES(NotImplemented, GroupClass::Make({fixed_size_list(int32(), 5)})); - ASSERT_RAISES(NotImplemented, Grouper::Make({struct_({})})); + ASSERT_RAISES(NotImplemented, GroupClass::Make({dense_union({field("", int32())})})); +} - ASSERT_RAISES(NotImplemented, Grouper::Make({list(int32())})); +void TestSegments(std::unique_ptr<RowSegmenter>& segmenter, const ExecSpan& batch, Review Comment: There are [plenty of (pre-PR) existing `Grouper` tests](https://github.com/apache/arrow/blob/237705bf17486cfc35ab7d1ddfe59dd60f042ab8/cpp/src/arrow/compute/kernels/hash_aggregate_test.cc#L309-L784) in `hash_aggregate_test.cc`. I think such refactoring, if needed, should not be part of this PR. -- 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-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org