Skip to content

Commit 249ba03

Browse files
Jasmine-geyl-lisen
andauthored
fix test and comment (#902)
support group array last Introduce groupArrayLast() (useful to store last X values) (#44521) * Cleanup DataTypeCustomSimpleAggregateFunction::checkSupportedFunctions() Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Remove unused GroupArrayGeneralListImpl Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Introduce groupArrayLast() (useful to store last X values) Also do some refactoring to make code cleaner: - rename insert() to insertWithSampler() (since it is used only for groupArraySample()) - split merge methods into Last/RNG/... Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> Bugfix/issue 7122 group array missing arg (#7135) (#7198) Co-authored-by: Lisen <38773813+yl-lisen@users.noreply.github.com>
1 parent f087cf2 commit 249ba03

8 files changed

+395
-113
lines changed

src/AggregateFunctions/AggregateFunctionGroupArray.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ inline AggregateFunctionPtr createAggregateFunctionGroupArrayImpl(const DataType
4848
// return std::make_shared<GroupArrayGeneralListImpl<GroupArrayListNodeGeneral, Trait>>(argument_type, std::forward<TArgs>(args)...);
4949
}
5050

51-
51+
template <bool Tlast>
5252
AggregateFunctionPtr createAggregateFunctionGroupArray(
5353
const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings *)
5454
{
@@ -79,9 +79,9 @@ AggregateFunctionPtr createAggregateFunctionGroupArray(
7979
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
8080

8181
if (!limit_size)
82-
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait<false, Sampler::NONE>>(argument_types[0], parameters);
82+
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait<false, Tlast, Sampler::NONE>>(argument_types[0], parameters);
8383
else
84-
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait<true, Sampler::NONE>>(argument_types[0], parameters, max_elems);
84+
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait<true, Tlast, Sampler::NONE>>(argument_types[0], parameters, max_elems);
8585
}
8686

8787
AggregateFunctionPtr createAggregateFunctionGroupArraySample(
@@ -114,7 +114,7 @@ AggregateFunctionPtr createAggregateFunctionGroupArraySample(
114114
else
115115
seed = thread_local_rng();
116116

117-
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait<true, Sampler::RNG>>(argument_types[0], parameters, max_elems, seed);
117+
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait<true, /* Tlast= */ false, Sampler::RNG>>(argument_types[0], parameters, max_elems, seed);
118118
}
119119

120120
}
@@ -124,8 +124,9 @@ void registerAggregateFunctionGroupArray(AggregateFunctionFactory & factory)
124124
{
125125
AggregateFunctionProperties properties = { .returns_default_when_only_null = false, .is_order_dependent = true };
126126

127-
factory.registerFunction("group_array", { createAggregateFunctionGroupArray, properties });
127+
factory.registerFunction("group_array", { createAggregateFunctionGroupArray<false>, properties });
128128
factory.registerFunction("group_array_sample", { createAggregateFunctionGroupArraySample, properties });
129+
factory.registerFunction("group_array_last", { createAggregateFunctionGroupArray<true>, properties });
129130
}
130131

131132
}

0 commit comments

Comments
 (0)