Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
R-JunmingChen committed Aug 12, 2023
1 parent 649d69f commit aa20a10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
13 changes: 8 additions & 5 deletions cpp/src/arrow/compute/kernels/aggregate_basic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -492,16 +492,17 @@ Result<std::unique_ptr<KernelState>> MinMaxInit(KernelContext* ctx,
return visitor.Create();
}

namespace{
namespace {

Result<TypeHolder> DictionaryValueType(KernelContext*, const std::vector<TypeHolder>& types) {
Result<TypeHolder> DictionaryValueType(KernelContext*,
const std::vector<TypeHolder>& types) {
// T -> T.value_type
auto ty = types.front();
const DictionaryType& ty_dict = checked_cast<const DictionaryType&>(*ty);
return ty_dict.value_type();
}

} //namespace
} // namespace

// For "min" and "max" functions: override finalize and return the actual value
template <MinOrMax min_or_max>
Expand Down Expand Up @@ -888,11 +889,13 @@ Result<TypeHolder> MinMaxType(KernelContext*, const std::vector<TypeHolder>& typ
return struct_({field("min", ty), field("max", ty)});
}

Result<TypeHolder> DictionaryMinMaxType(KernelContext*, const std::vector<TypeHolder>& types) {
Result<TypeHolder> DictionaryMinMaxType(KernelContext*,
const std::vector<TypeHolder>& types) {
// T -> struct<min: T.value_type, max: T.value_type>
auto ty = types.front();
const DictionaryType& ty_dict = checked_cast<const DictionaryType&>(*ty);
return struct_({field("min", ty_dict.value_type()), field("max", ty_dict.value_type())});
return struct_(
{field("min", ty_dict.value_type()), field("max", ty_dict.value_type())});
}

} // namespace
Expand Down
11 changes: 6 additions & 5 deletions cpp/src/arrow/compute/kernels/aggregate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,6 @@ TEST(TestDecimalMinMaxKernel, Decimals) {

TEST(TestDictionaryMinMaxKernel, DictionaryArray) {
ScalarAggregateOptions options;
std::shared_ptr<arrow::DataType> item_ty;
std::shared_ptr<arrow::DataType> dict_ty;
std::shared_ptr<arrow::DataType> ty;
for (const auto& index_type : all_dictionary_index_types()) {
Expand Down Expand Up @@ -2078,8 +2077,9 @@ TEST(TestDictionaryMinMaxKernel, DictionaryArray) {
ResultWith(ScalarFromJSON(ty, R"({"min": "-1.23", "max": "5.10"})")));

options = ScalarAggregateOptions(/*skip_nulls=*/true, /*min_count=*/0);
EXPECT_THAT(MinMax(DictArrayFromJSON(dict_ty, R"([null, null, null])", R"([])"), options),
ResultWith(ScalarFromJSON(ty, R"({"min": null, "max": null})")));
EXPECT_THAT(
MinMax(DictArrayFromJSON(dict_ty, R"([null, null, null])", R"([])"), options),
ResultWith(ScalarFromJSON(ty, R"({"min": null, "max": null})")));
EXPECT_THAT(MinMax(DictArrayFromJSON(dict_ty, R"([0])", R"(["1.00"])"), options),
ResultWith(ScalarFromJSON(ty, R"({"min": "1.00", "max": "1.00"})")));

Expand All @@ -2095,8 +2095,9 @@ TEST(TestDictionaryMinMaxKernel, DictionaryArray) {
ResultWith(ScalarFromJSON(ty, R"({"min": "-1.23", "max": "5.10"})")));

options = ScalarAggregateOptions(/*skip_nulls=*/true, /*min_count=*/1);
EXPECT_THAT(MinMax(DictArrayFromJSON(dict_ty, R"([null, null, null])", R"([])"), options),
ResultWith(ScalarFromJSON(ty, R"({"min": null, "max": null})")));
EXPECT_THAT(
MinMax(DictArrayFromJSON(dict_ty, R"([null, null, null])", R"([])"), options),
ResultWith(ScalarFromJSON(ty, R"({"min": null, "max": null})")));
EXPECT_THAT(MinMax(DictArrayFromJSON(dict_ty, R"([0])", R"(["1.00"])"), options),
ResultWith(ScalarFromJSON(ty, R"({"min": "1.00", "max": "1.00"})")));
}
Expand Down

0 comments on commit aa20a10

Please sign in to comment.