[Enchancement](function) remove unused params on aggregate function (#16886)
remove unused params on aggregate function
This commit is contained in:
@ -89,7 +89,7 @@ void MemTable::_init_agg_functions(const vectorized::Block* block) {
|
||||
// In such table, non-key column's aggregation type is NONE, so we need to construct
|
||||
// the aggregate function manually.
|
||||
function = vectorized::AggregateFunctionSimpleFactory::instance().get(
|
||||
"replace_load", {block->get_data_type(cid)}, {},
|
||||
"replace_load", {block->get_data_type(cid)},
|
||||
block->get_data_type(cid)->is_nullable());
|
||||
} else {
|
||||
function = _tablet_schema->column(cid).get_aggregate_function(
|
||||
|
||||
@ -492,7 +492,7 @@ vectorized::AggregateFunctionPtr TabletColumn::get_aggregate_function(
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
|
||||
return vectorized::AggregateFunctionSimpleFactory::instance().get(
|
||||
agg_name, argument_types, {}, argument_types.back()->is_nullable());
|
||||
agg_name, argument_types, argument_types.back()->is_nullable());
|
||||
}
|
||||
|
||||
void TabletIndex::init_from_thrift(const TOlapTableIndex& index,
|
||||
|
||||
@ -58,8 +58,7 @@ using ConstAggregateDataPtr = const char*;
|
||||
*/
|
||||
class IAggregateFunction {
|
||||
public:
|
||||
IAggregateFunction(const DataTypes& argument_types_, const Array& parameters_)
|
||||
: argument_types(argument_types_), parameters(parameters_) {}
|
||||
IAggregateFunction(const DataTypes& argument_types_) : argument_types(argument_types_) {}
|
||||
|
||||
/// Get main function name.
|
||||
virtual String get_name() const = 0;
|
||||
@ -192,7 +191,6 @@ public:
|
||||
const size_t num_rows, Arena* arena) const = 0;
|
||||
|
||||
const DataTypes& get_argument_types() const { return argument_types; }
|
||||
const Array& get_parameters() const { return parameters; }
|
||||
|
||||
virtual MutableColumnPtr create_serialize_column() const { return ColumnString::create(); }
|
||||
|
||||
@ -200,15 +198,14 @@ public:
|
||||
|
||||
protected:
|
||||
DataTypes argument_types;
|
||||
Array parameters;
|
||||
};
|
||||
|
||||
/// Implement method to obtain an address of 'add' function.
|
||||
template <typename Derived>
|
||||
class IAggregateFunctionHelper : public IAggregateFunction {
|
||||
public:
|
||||
IAggregateFunctionHelper(const DataTypes& argument_types_, const Array& parameters_)
|
||||
: IAggregateFunction(argument_types_, parameters_) {}
|
||||
IAggregateFunctionHelper(const DataTypes& argument_types_)
|
||||
: IAggregateFunction(argument_types_) {}
|
||||
|
||||
void destroy_vec(AggregateDataPtr __restrict place,
|
||||
const size_t num_rows) const noexcept override {
|
||||
@ -381,8 +378,8 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
IAggregateFunctionDataHelper(const DataTypes& argument_types_, const Array& parameters_)
|
||||
: IAggregateFunctionHelper<Derived>(argument_types_, parameters_) {}
|
||||
IAggregateFunctionDataHelper(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionHelper<Derived>(argument_types_) {}
|
||||
|
||||
void create(AggregateDataPtr __restrict place) const override { new (place) Data; }
|
||||
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
namespace doris::vectorized {
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_approx_count_distinct(
|
||||
const std::string& name, const DataTypes& argument_types, const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) {
|
||||
AggregateFunctionPtr res = nullptr;
|
||||
WhichDataType which(argument_types[0]->is_nullable()
|
||||
? reinterpret_cast<const DataTypeNullable*>(argument_types[0].get())
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
AggregateFunctionApproxCountDistinct(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<AggregateFunctionApproxCountDistinctData,
|
||||
AggregateFunctionApproxCountDistinct<ColumnDataType>>(
|
||||
argument_types_, {}) {}
|
||||
argument_types_) {}
|
||||
|
||||
DataTypePtr get_return_type() const override { return std::make_shared<DataTypeInt64>(); }
|
||||
|
||||
|
||||
@ -38,9 +38,7 @@ using AggregateFuncAvg = typename Avg<T>::Function;
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_avg(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
assert_unary(name, argument_types);
|
||||
|
||||
AggregateFunctionPtr res;
|
||||
@ -49,11 +47,10 @@ AggregateFunctionPtr create_aggregate_function_avg(const std::string& name,
|
||||
auto no_null_argument_types = remove_nullable(argument_types);
|
||||
if (is_decimal(no_null_argument_types[0])) {
|
||||
res.reset(create_with_decimal_type_null<AggregateFuncAvg>(
|
||||
no_null_argument_types, parameters, *no_null_argument_types[0],
|
||||
no_null_argument_types));
|
||||
no_null_argument_types, *no_null_argument_types[0], no_null_argument_types));
|
||||
} else {
|
||||
res.reset(create_with_numeric_type_null<AggregateFuncAvg>(
|
||||
no_null_argument_types, parameters, no_null_argument_types));
|
||||
res.reset(create_with_numeric_type_null<AggregateFuncAvg>(no_null_argument_types,
|
||||
no_null_argument_types));
|
||||
}
|
||||
} else {
|
||||
if (is_decimal(data_type)) {
|
||||
|
||||
@ -94,14 +94,12 @@ public:
|
||||
|
||||
/// ctor for native types
|
||||
AggregateFunctionAvg(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionAvg<T, Data>>(argument_types_,
|
||||
{}),
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionAvg<T, Data>>(argument_types_),
|
||||
scale(0) {}
|
||||
|
||||
/// ctor for Decimals
|
||||
AggregateFunctionAvg(const IDataType& data_type, const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionAvg<T, Data>>(argument_types_,
|
||||
{}),
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionAvg<T, Data>>(argument_types_),
|
||||
scale(get_decimal_scale(data_type)) {}
|
||||
|
||||
String get_name() const override { return "avg"; }
|
||||
|
||||
@ -24,7 +24,6 @@ namespace doris::vectorized {
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_avg_weight(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
auto type = argument_types[0].get();
|
||||
if (type->is_nullable()) {
|
||||
|
||||
@ -73,7 +73,7 @@ public:
|
||||
|
||||
AggregateFunctionAvgWeight(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<AggregateFunctionAvgWeightedData<T>,
|
||||
AggregateFunctionAvgWeight<T>>(argument_types_, {}) {}
|
||||
AggregateFunctionAvgWeight<T>>(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "avg_weighted"; }
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ namespace doris::vectorized {
|
||||
template <template <typename> class Data>
|
||||
AggregateFunctionPtr createAggregateFunctionBitwise(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
if (!argument_types[0]->can_be_used_in_bit_operations()) {
|
||||
LOG(WARNING) << fmt::format("The type " + argument_types[0]->get_name() +
|
||||
|
||||
@ -91,8 +91,8 @@ class AggregateFunctionBitwise final
|
||||
: public IAggregateFunctionDataHelper<Data, AggregateFunctionBitwise<T, Data>> {
|
||||
public:
|
||||
AggregateFunctionBitwise(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionBitwise<T, Data>>(argument_types_,
|
||||
{}) {}
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionBitwise<T, Data>>(
|
||||
argument_types_) {}
|
||||
|
||||
String get_name() const override { return Data::name; }
|
||||
|
||||
|
||||
@ -45,7 +45,6 @@ static IAggregateFunction* createWithIntDataType(const DataTypes& argument_type)
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_bitmap_union(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return std::make_shared<AggregateFunctionBitmapOp<AggregateFunctionBitmapUnionOp>>(
|
||||
argument_types);
|
||||
@ -53,7 +52,6 @@ AggregateFunctionPtr create_aggregate_function_bitmap_union(const std::string& n
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_bitmap_intersect(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return std::make_shared<AggregateFunctionBitmapOp<AggregateFunctionBitmapIntersectOp>>(
|
||||
argument_types);
|
||||
@ -61,7 +59,6 @@ AggregateFunctionPtr create_aggregate_function_bitmap_intersect(const std::strin
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_group_bitmap_xor(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return std::make_shared<AggregateFunctionBitmapOp<AggregateFunctionGroupBitmapXorOp>>(
|
||||
argument_types);
|
||||
@ -69,7 +66,6 @@ AggregateFunctionPtr create_aggregate_function_group_bitmap_xor(const std::strin
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_bitmap_union_count(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
const bool arg_is_nullable = argument_types[0]->is_nullable();
|
||||
if (arg_is_nullable) {
|
||||
@ -81,7 +77,6 @@ AggregateFunctionPtr create_aggregate_function_bitmap_union_count(const std::str
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_bitmap_union_int(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
const bool arg_is_nullable = argument_types[0]->is_nullable();
|
||||
if (arg_is_nullable) {
|
||||
|
||||
@ -142,7 +142,7 @@ public:
|
||||
|
||||
AggregateFunctionBitmapOp(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<AggregateFunctionBitmapData<Op>,
|
||||
AggregateFunctionBitmapOp<Op>>(argument_types_, {}) {}
|
||||
AggregateFunctionBitmapOp<Op>>(argument_types_) {}
|
||||
|
||||
DataTypePtr get_return_type() const override { return std::make_shared<DataTypeBitMap>(); }
|
||||
|
||||
@ -201,8 +201,7 @@ public:
|
||||
AggregateFunctionBitmapCount(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<
|
||||
AggregateFunctionBitmapData<AggregateFunctionBitmapUnionOp>,
|
||||
AggregateFunctionBitmapCount<arg_is_nullable, ColVecType>>(argument_types_,
|
||||
{}) {}
|
||||
AggregateFunctionBitmapCount<arg_is_nullable, ColVecType>>(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "count"; }
|
||||
DataTypePtr get_return_type() const override { return std::make_shared<DataTypeInt64>(); }
|
||||
@ -270,7 +269,6 @@ public:
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_bitmap_union(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable);
|
||||
|
||||
} // namespace doris::vectorized
|
||||
@ -34,7 +34,6 @@ AggregateFunctionPtr create_agg_function_collect(bool distinct, const DataTypes&
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_collect(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
if (argument_types.size() != 1) {
|
||||
LOG(WARNING) << fmt::format("Illegal number {} of argument for aggregate function {}",
|
||||
|
||||
@ -189,8 +189,7 @@ public:
|
||||
std::is_same_v<Data, AggregateFunctionCollectSetData<StringRef>>;
|
||||
|
||||
AggregateFunctionCollect(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionCollect<Data>>(argument_types_,
|
||||
{}),
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionCollect<Data>>(argument_types_),
|
||||
_argument_type(argument_types_[0]) {}
|
||||
|
||||
std::string get_name() const override {
|
||||
|
||||
@ -58,12 +58,6 @@ public:
|
||||
*/
|
||||
virtual DataTypes transform_arguments(const DataTypes& arguments) const { return arguments; }
|
||||
|
||||
/** From the parameters for combined function,
|
||||
* get the parameters for nested function.
|
||||
* If arguments are not suitable for combined function, throw an exception.
|
||||
*/
|
||||
virtual Array transform_parameters(const Array& parameters) const { return parameters; }
|
||||
|
||||
/** Create combined aggregate function (ex: sumIf)
|
||||
* from nested function (ex: sum)
|
||||
* and arguments for combined aggregate function (ex: UInt64, UInt8 for sumIf).
|
||||
@ -71,7 +65,7 @@ public:
|
||||
*/
|
||||
virtual AggregateFunctionPtr transform_aggregate_function(
|
||||
const AggregateFunctionPtr& nested_function, const DataTypes& arguments,
|
||||
const Array& params, const bool result_is_nullable) const = 0;
|
||||
const bool result_is_nullable) const = 0;
|
||||
|
||||
virtual ~IAggregateFunctionCombinator() = default;
|
||||
};
|
||||
|
||||
@ -27,9 +27,7 @@ namespace doris::vectorized {
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_count(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
assert_arity_at_most<1>(name, argument_types);
|
||||
|
||||
return std::make_shared<AggregateFunctionCount>(argument_types);
|
||||
@ -37,7 +35,6 @@ AggregateFunctionPtr create_aggregate_function_count(const std::string& name,
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_count_not_null_unary(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_arity_at_most<1>(name, argument_types);
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ class AggregateFunctionCount final
|
||||
: public IAggregateFunctionDataHelper<AggregateFunctionCountData, AggregateFunctionCount> {
|
||||
public:
|
||||
AggregateFunctionCount(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper(argument_types_, {}) {}
|
||||
: IAggregateFunctionDataHelper(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "count"; }
|
||||
|
||||
@ -128,7 +128,7 @@ class AggregateFunctionCountNotNullUnary final
|
||||
AggregateFunctionCountNotNullUnary> {
|
||||
public:
|
||||
AggregateFunctionCountNotNullUnary(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper(argument_types_, {}) {}
|
||||
: IAggregateFunctionDataHelper(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "count"; }
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
|
||||
#include "vec/aggregate_functions/helpers.h"
|
||||
#include "vec/common/typeid_cast.h"
|
||||
#include "vec/data_types/data_type.h"
|
||||
#include "vec/data_types/data_type_nullable.h"
|
||||
|
||||
namespace doris::vectorized {
|
||||
@ -42,7 +43,7 @@ public:
|
||||
|
||||
AggregateFunctionPtr transform_aggregate_function(
|
||||
const AggregateFunctionPtr& nested_function, const DataTypes& arguments,
|
||||
const Array& params, const bool result_is_nullable) const override {
|
||||
const bool result_is_nullable) const override {
|
||||
DCHECK(nested_function != nullptr);
|
||||
if (nested_function == nullptr) {
|
||||
return nullptr;
|
||||
@ -79,7 +80,7 @@ const std::string DISTINCT_FUNCTION_PREFIX = "multi_distinct_";
|
||||
|
||||
void register_aggregate_function_combinator_distinct(AggregateFunctionSimpleFactory& factory) {
|
||||
AggregateFunctionCreator creator = [&](const std::string& name, const DataTypes& types,
|
||||
const Array& params, const bool result_is_nullable) {
|
||||
const bool result_is_nullable) {
|
||||
// 1. we should get not nullable types;
|
||||
DataTypes nested_types(types.size());
|
||||
std::transform(types.begin(), types.end(), nested_types.begin(),
|
||||
@ -87,8 +88,8 @@ void register_aggregate_function_combinator_distinct(AggregateFunctionSimpleFact
|
||||
auto function_combinator = std::make_shared<AggregateFunctionCombinatorDistinct>();
|
||||
auto transform_arguments = function_combinator->transform_arguments(nested_types);
|
||||
auto nested_function_name = name.substr(DISTINCT_FUNCTION_PREFIX.size());
|
||||
auto nested_function = factory.get(nested_function_name, transform_arguments, params);
|
||||
return function_combinator->transform_aggregate_function(nested_function, types, params,
|
||||
auto nested_function = factory.get(nested_function_name, transform_arguments);
|
||||
return function_combinator->transform_aggregate_function(nested_function, types,
|
||||
result_is_nullable);
|
||||
};
|
||||
factory.register_distinct_function_combinator(creator, DISTINCT_FUNCTION_PREFIX);
|
||||
|
||||
@ -168,8 +168,7 @@ private:
|
||||
|
||||
public:
|
||||
AggregateFunctionDistinct(AggregateFunctionPtr nested_func_, const DataTypes& arguments)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionDistinct>(
|
||||
arguments, nested_func_->get_parameters()),
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionDistinct>(arguments),
|
||||
nested_func(nested_func_),
|
||||
arguments_num(arguments.size()) {
|
||||
size_t nested_size = nested_func->align_of_data();
|
||||
|
||||
@ -23,7 +23,6 @@ const std::string AggregateFunctionGroupConcatImplStr::separator = ", ";
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_group_concat(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
if (argument_types.size() == 1) {
|
||||
return AggregateFunctionPtr(
|
||||
|
||||
@ -103,8 +103,7 @@ class AggregateFunctionGroupConcat final
|
||||
public:
|
||||
AggregateFunctionGroupConcat(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<AggregateFunctionGroupConcatData,
|
||||
AggregateFunctionGroupConcat<Impl>>(argument_types_,
|
||||
{}) {}
|
||||
AggregateFunctionGroupConcat<Impl>>(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "group_concat"; }
|
||||
|
||||
|
||||
@ -39,7 +39,6 @@ AggregateFunctionPtr create_agg_function_histogram(const DataTypes& argument_typ
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_histogram(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
WhichDataType type(argument_types[0]);
|
||||
|
||||
|
||||
@ -151,7 +151,7 @@ public:
|
||||
AggregateFunctionHistogram(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data,
|
||||
AggregateFunctionHistogram<Data, T, has_input_param>>(
|
||||
argument_types_, {}),
|
||||
argument_types_),
|
||||
_argument_type(argument_types_[0]) {}
|
||||
|
||||
std::string get_name() const override { return "histogram"; }
|
||||
|
||||
@ -25,9 +25,7 @@ namespace doris::vectorized {
|
||||
template <bool is_nullable>
|
||||
AggregateFunctionPtr create_aggregate_function_HLL_union_agg(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
assert_arity_at_most<1>(name, argument_types);
|
||||
|
||||
return std::make_shared<AggregateFunctionHLLUnion<
|
||||
@ -38,9 +36,7 @@ AggregateFunctionPtr create_aggregate_function_HLL_union_agg(const std::string&
|
||||
template <bool is_nullable>
|
||||
AggregateFunctionPtr create_aggregate_function_HLL_union(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
assert_arity_at_most<1>(name, argument_types);
|
||||
|
||||
return std::make_shared<AggregateFunctionHLLUnion<
|
||||
|
||||
@ -98,8 +98,7 @@ class AggregateFunctionHLLUnion
|
||||
: public IAggregateFunctionDataHelper<Data, AggregateFunctionHLLUnion<Data>> {
|
||||
public:
|
||||
AggregateFunctionHLLUnion(const DataTypes& argument_types)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionHLLUnion<Data>>(argument_types,
|
||||
{}) {}
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionHLLUnion<Data>>(argument_types) {}
|
||||
|
||||
String get_name() const override { return Data::name(); }
|
||||
|
||||
@ -134,7 +133,6 @@ public:
|
||||
template <bool is_nullable = false>
|
||||
AggregateFunctionPtr create_aggregate_function_HLL_union(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable);
|
||||
|
||||
} // namespace doris::vectorized
|
||||
|
||||
@ -299,9 +299,9 @@ private:
|
||||
class AggregateJavaUdaf final
|
||||
: public IAggregateFunctionDataHelper<AggregateJavaUdafData, AggregateJavaUdaf> {
|
||||
public:
|
||||
AggregateJavaUdaf(const TFunction& fn, const DataTypes& argument_types, const Array& parameters,
|
||||
AggregateJavaUdaf(const TFunction& fn, const DataTypes& argument_types,
|
||||
const DataTypePtr& return_type)
|
||||
: IAggregateFunctionDataHelper(argument_types, parameters),
|
||||
: IAggregateFunctionDataHelper(argument_types),
|
||||
_fn(fn),
|
||||
_return_type(return_type),
|
||||
_first_created(true),
|
||||
@ -309,8 +309,8 @@ public:
|
||||
~AggregateJavaUdaf() = default;
|
||||
|
||||
static AggregateFunctionPtr create(const TFunction& fn, const DataTypes& argument_types,
|
||||
const Array& parameters, const DataTypePtr& return_type) {
|
||||
return std::make_shared<AggregateJavaUdaf>(fn, argument_types, parameters, return_type);
|
||||
const DataTypePtr& return_type) {
|
||||
return std::make_shared<AggregateJavaUdaf>(fn, argument_types, return_type);
|
||||
}
|
||||
//Note: The condition is added because maybe the BE can't find java-udaf impl jar
|
||||
//So need to check as soon as possible, before call Data function
|
||||
|
||||
@ -28,9 +28,7 @@ namespace doris::vectorized {
|
||||
/// min, max, any
|
||||
template <template <typename, bool> class AggregateFunctionTemplate, template <typename> class Data>
|
||||
static IAggregateFunction* create_aggregate_function_single_value(const String& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters) {
|
||||
assert_no_parameters(name, parameters);
|
||||
const DataTypes& argument_types) {
|
||||
assert_unary(name, argument_types);
|
||||
|
||||
const DataTypePtr& argument_type = argument_types[0];
|
||||
@ -78,32 +76,26 @@ static IAggregateFunction* create_aggregate_function_single_value(const String&
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_max(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(
|
||||
create_aggregate_function_single_value<AggregateFunctionsSingleValue,
|
||||
AggregateFunctionMaxData>(name, argument_types,
|
||||
parameters));
|
||||
AggregateFunctionMaxData>(name, argument_types));
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_min(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(
|
||||
create_aggregate_function_single_value<AggregateFunctionsSingleValue,
|
||||
AggregateFunctionMinData>(name, argument_types,
|
||||
parameters));
|
||||
AggregateFunctionMinData>(name, argument_types));
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_any(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(
|
||||
create_aggregate_function_single_value<AggregateFunctionsSingleValue,
|
||||
AggregateFunctionAnyData>(name, argument_types,
|
||||
parameters));
|
||||
AggregateFunctionAnyData>(name, argument_types));
|
||||
}
|
||||
|
||||
void register_aggregate_function_minmax(AggregateFunctionSimpleFactory& factory) {
|
||||
|
||||
@ -497,8 +497,7 @@ private:
|
||||
public:
|
||||
AggregateFunctionsSingleValue(const DataTypePtr& type_)
|
||||
: IAggregateFunctionDataHelper<
|
||||
Data, AggregateFunctionsSingleValue<Data, AllocatesMemoryInArena>>({type_},
|
||||
{}),
|
||||
Data, AggregateFunctionsSingleValue<Data, AllocatesMemoryInArena>>({type_}),
|
||||
type(this->argument_types[0]) {
|
||||
if (StringRef(Data::name()) == StringRef("min") ||
|
||||
StringRef(Data::name()) == StringRef("max")) {
|
||||
@ -628,17 +627,14 @@ public:
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_max(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable);
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_min(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable);
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_any(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable);
|
||||
|
||||
} // namespace doris::vectorized
|
||||
|
||||
@ -75,9 +75,7 @@ static IAggregateFunction* create_aggregate_function_min_max_by_impl(
|
||||
template <template <typename, bool> class AggregateFunctionTemplate,
|
||||
template <typename, typename> class Data>
|
||||
static IAggregateFunction* create_aggregate_function_min_max_by(const String& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters) {
|
||||
assert_no_parameters(name, parameters);
|
||||
const DataTypes& argument_types) {
|
||||
assert_binary(name, argument_types);
|
||||
|
||||
const DataTypePtr& value_arg_type = argument_types[0];
|
||||
@ -129,20 +127,18 @@ static IAggregateFunction* create_aggregate_function_min_max_by(const String& na
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_max_by(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(create_aggregate_function_min_max_by<AggregateFunctionsMinMaxBy,
|
||||
AggregateFunctionMaxByData>(
|
||||
name, argument_types, parameters));
|
||||
return AggregateFunctionPtr(
|
||||
create_aggregate_function_min_max_by<AggregateFunctionsMinMaxBy,
|
||||
AggregateFunctionMaxByData>(name, argument_types));
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_min_by(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(create_aggregate_function_min_max_by<AggregateFunctionsMinMaxBy,
|
||||
AggregateFunctionMinByData>(
|
||||
name, argument_types, parameters));
|
||||
return AggregateFunctionPtr(
|
||||
create_aggregate_function_min_max_by<AggregateFunctionsMinMaxBy,
|
||||
AggregateFunctionMinByData>(name, argument_types));
|
||||
}
|
||||
|
||||
void register_aggregate_function_min_max_by(AggregateFunctionSimpleFactory& factory) {
|
||||
|
||||
@ -107,7 +107,7 @@ public:
|
||||
AggregateFunctionsMinMaxBy(const DataTypePtr& value_type_, const DataTypePtr& key_type_)
|
||||
: IAggregateFunctionDataHelper<
|
||||
Data, AggregateFunctionsMinMaxBy<Data, AllocatesMemoryInArena>>(
|
||||
{value_type_, key_type_}, {}),
|
||||
{value_type_, key_type_}),
|
||||
value_type(this->argument_types[0]),
|
||||
key_type(this->argument_types[1]) {
|
||||
if (StringRef(Data::name()) == StringRef("min_by") ||
|
||||
@ -150,12 +150,10 @@ public:
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_max_by(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable);
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_min_by(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable);
|
||||
|
||||
} // namespace doris::vectorized
|
||||
|
||||
@ -32,8 +32,8 @@ namespace doris::vectorized {
|
||||
*/
|
||||
class AggregateFunctionNothing final : public IAggregateFunctionHelper<AggregateFunctionNothing> {
|
||||
public:
|
||||
AggregateFunctionNothing(const DataTypes& arguments, const Array& params)
|
||||
: IAggregateFunctionHelper<AggregateFunctionNothing>(arguments, params) {}
|
||||
AggregateFunctionNothing(const DataTypes& arguments)
|
||||
: IAggregateFunctionHelper<AggregateFunctionNothing>(arguments) {}
|
||||
|
||||
String get_name() const override { return "nothing"; }
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
|
||||
AggregateFunctionPtr transform_aggregate_function(
|
||||
const AggregateFunctionPtr& nested_function, const DataTypes& arguments,
|
||||
const Array& params, const bool result_is_nullable) const override {
|
||||
const bool result_is_nullable) const override {
|
||||
if (nested_function == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -61,24 +61,24 @@ public:
|
||||
}
|
||||
|
||||
if (has_null_types) {
|
||||
return std::make_shared<AggregateFunctionNothing>(arguments, params);
|
||||
return std::make_shared<AggregateFunctionNothing>(arguments);
|
||||
}
|
||||
|
||||
if (arguments.size() == 1) {
|
||||
if (result_is_nullable) {
|
||||
return std::make_shared<AggregateFunctionNullUnary<true>>(nested_function,
|
||||
arguments, params);
|
||||
arguments);
|
||||
} else {
|
||||
return std::make_shared<AggregateFunctionNullUnary<false>>(nested_function,
|
||||
arguments, params);
|
||||
arguments);
|
||||
}
|
||||
} else {
|
||||
if (result_is_nullable) {
|
||||
return std::make_shared<AggregateFunctionNullVariadic<true>>(nested_function,
|
||||
arguments, params);
|
||||
arguments);
|
||||
} else {
|
||||
return std::make_shared<AggregateFunctionNullVariadic<false>>(nested_function,
|
||||
arguments, params);
|
||||
arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,11 +86,11 @@ public:
|
||||
|
||||
void register_aggregate_function_combinator_null(AggregateFunctionSimpleFactory& factory) {
|
||||
AggregateFunctionCreator creator = [&](const std::string& name, const DataTypes& types,
|
||||
const Array& params, const bool result_is_nullable) {
|
||||
const bool result_is_nullable) {
|
||||
auto function_combinator = std::make_shared<AggregateFunctionCombinatorNull>();
|
||||
auto transform_arguments = function_combinator->transform_arguments(types);
|
||||
auto nested_function = factory.get(name, transform_arguments, params);
|
||||
return function_combinator->transform_aggregate_function(nested_function, types, params,
|
||||
auto nested_function = factory.get(name, transform_arguments);
|
||||
return function_combinator->transform_aggregate_function(nested_function, types,
|
||||
result_is_nullable);
|
||||
};
|
||||
factory.register_nullable_function_combinator(creator);
|
||||
|
||||
@ -79,10 +79,8 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
AggregateFunctionNullBase(AggregateFunctionPtr nested_function_, const DataTypes& arguments,
|
||||
const Array& params)
|
||||
: IAggregateFunctionHelper<Derived>(arguments, params),
|
||||
nested_function {nested_function_} {
|
||||
AggregateFunctionNullBase(AggregateFunctionPtr nested_function_, const DataTypes& arguments)
|
||||
: IAggregateFunctionHelper<Derived>(arguments), nested_function {nested_function_} {
|
||||
if (result_is_nullable) {
|
||||
prefix_size = nested_function->align_of_data();
|
||||
} else {
|
||||
@ -204,11 +202,10 @@ class AggregateFunctionNullUnary final
|
||||
: public AggregateFunctionNullBase<result_is_nullable,
|
||||
AggregateFunctionNullUnary<result_is_nullable>> {
|
||||
public:
|
||||
AggregateFunctionNullUnary(AggregateFunctionPtr nested_function_, const DataTypes& arguments,
|
||||
const Array& params)
|
||||
AggregateFunctionNullUnary(AggregateFunctionPtr nested_function_, const DataTypes& arguments)
|
||||
: AggregateFunctionNullBase<result_is_nullable,
|
||||
AggregateFunctionNullUnary<result_is_nullable>>(
|
||||
std::move(nested_function_), arguments, params) {}
|
||||
std::move(nested_function_), arguments) {}
|
||||
|
||||
void add(AggregateDataPtr __restrict place, const IColumn** columns, size_t row_num,
|
||||
Arena* arena) const override {
|
||||
@ -351,11 +348,10 @@ class AggregateFunctionNullVariadic final
|
||||
: public AggregateFunctionNullBase<result_is_nullable,
|
||||
AggregateFunctionNullVariadic<result_is_nullable>> {
|
||||
public:
|
||||
AggregateFunctionNullVariadic(AggregateFunctionPtr nested_function_, const DataTypes& arguments,
|
||||
const Array& params)
|
||||
AggregateFunctionNullVariadic(AggregateFunctionPtr nested_function_, const DataTypes& arguments)
|
||||
: AggregateFunctionNullBase<result_is_nullable,
|
||||
AggregateFunctionNullVariadic<result_is_nullable>>(
|
||||
std::move(nested_function_), arguments, params),
|
||||
std::move(nested_function_), arguments),
|
||||
number_of_arguments(arguments.size()) {
|
||||
if (number_of_arguments == 1) {
|
||||
LOG(FATAL)
|
||||
@ -449,8 +445,8 @@ protected:
|
||||
|
||||
public:
|
||||
AggregateFunctionNullBaseInline(IAggregateFunction* nested_function_,
|
||||
const DataTypes& arguments, const Array& params)
|
||||
: IAggregateFunctionHelper<Derived>(arguments, params),
|
||||
const DataTypes& arguments)
|
||||
: IAggregateFunctionHelper<Derived>(arguments),
|
||||
nested_function {assert_cast<NestFunction*>(nested_function_)} {
|
||||
if (result_is_nullable) {
|
||||
prefix_size = nested_function->align_of_data();
|
||||
@ -575,11 +571,11 @@ class AggregateFunctionNullUnaryInline final
|
||||
AggregateFunctionNullUnaryInline<NestFuction, result_is_nullable>> {
|
||||
public:
|
||||
AggregateFunctionNullUnaryInline(IAggregateFunction* nested_function_,
|
||||
const DataTypes& arguments, const Array& params)
|
||||
const DataTypes& arguments)
|
||||
: AggregateFunctionNullBaseInline<
|
||||
NestFuction, result_is_nullable,
|
||||
AggregateFunctionNullUnaryInline<NestFuction, result_is_nullable>>(
|
||||
nested_function_, arguments, params) {}
|
||||
nested_function_, arguments) {}
|
||||
|
||||
void add(AggregateDataPtr __restrict place, const IColumn** columns, size_t row_num,
|
||||
Arena* arena) const override {
|
||||
|
||||
@ -28,7 +28,7 @@ namespace doris::vectorized {
|
||||
template <template <typename> class Impl>
|
||||
AggregateFunctionPtr create_aggregate_function_orthogonal(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& params,
|
||||
|
||||
const bool result_is_nullable) {
|
||||
if (argument_types.empty()) {
|
||||
LOG(WARNING) << "Incorrect number of arguments for aggregate function " << name;
|
||||
@ -55,32 +55,29 @@ AggregateFunctionPtr create_aggregate_function_orthogonal(const std::string& nam
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_orthogonal_bitmap_intersect(
|
||||
const std::string& name, const DataTypes& argument_types, const Array& parameters,
|
||||
bool result_is_nullable) {
|
||||
return create_aggregate_function_orthogonal<AggOrthBitMapIntersect>(
|
||||
name, argument_types, parameters, result_is_nullable);
|
||||
const std::string& name, const DataTypes& argument_types, bool result_is_nullable) {
|
||||
return create_aggregate_function_orthogonal<AggOrthBitMapIntersect>(name, argument_types,
|
||||
result_is_nullable);
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_orthogonal_bitmap_intersect_count(
|
||||
const std::string& name, const DataTypes& argument_types, const Array& parameters,
|
||||
bool result_is_nullable) {
|
||||
return create_aggregate_function_orthogonal<AggOrthBitMapIntersectCount>(
|
||||
name, argument_types, parameters, result_is_nullable);
|
||||
const std::string& name, const DataTypes& argument_types, bool result_is_nullable) {
|
||||
return create_aggregate_function_orthogonal<AggOrthBitMapIntersectCount>(name, argument_types,
|
||||
result_is_nullable);
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_intersect_count(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
|
||||
bool result_is_nullable) {
|
||||
return create_aggregate_function_orthogonal<AggIntersectCount>(name, argument_types, parameters,
|
||||
return create_aggregate_function_orthogonal<AggIntersectCount>(name, argument_types,
|
||||
result_is_nullable);
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_orthogonal_bitmap_union_count(
|
||||
const std::string& name, const DataTypes& argument_types, const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return create_aggregate_function_orthogonal<OrthBitmapUnionCountData>(
|
||||
name, argument_types, parameters, result_is_nullable);
|
||||
const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) {
|
||||
return create_aggregate_function_orthogonal<OrthBitmapUnionCountData>(name, argument_types,
|
||||
result_is_nullable);
|
||||
}
|
||||
|
||||
void register_aggregate_function_orthogonal_bitmap(AggregateFunctionSimpleFactory& factory) {
|
||||
|
||||
@ -215,8 +215,7 @@ public:
|
||||
String get_name() const override { return Impl::name; }
|
||||
|
||||
AggFunctionOrthBitmapFunc(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Impl, AggFunctionOrthBitmapFunc<Impl>>(argument_types_,
|
||||
{}),
|
||||
: IAggregateFunctionDataHelper<Impl, AggFunctionOrthBitmapFunc<Impl>>(argument_types_),
|
||||
_argument_size(argument_types_.size()) {}
|
||||
|
||||
DataTypePtr get_return_type() const override { return Impl::get_return_type(); }
|
||||
|
||||
@ -25,7 +25,6 @@ namespace doris::vectorized {
|
||||
template <bool is_nullable>
|
||||
AggregateFunctionPtr create_aggregate_function_percentile_approx(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
if (argument_types.size() == 1) {
|
||||
return std::make_shared<AggregateFunctionPercentileApproxMerge<is_nullable>>(
|
||||
@ -44,19 +43,13 @@ AggregateFunctionPtr create_aggregate_function_percentile_approx(const std::stri
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_percentile(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
|
||||
return std::make_shared<AggregateFunctionPercentile>(argument_types);
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_percentile_array(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
|
||||
return std::make_shared<AggregateFunctionPercentileArray>(argument_types);
|
||||
}
|
||||
|
||||
|
||||
@ -127,8 +127,7 @@ class AggregateFunctionPercentileApprox
|
||||
public:
|
||||
AggregateFunctionPercentileApprox(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<PercentileApproxState,
|
||||
AggregateFunctionPercentileApprox>(argument_types_, {}) {
|
||||
}
|
||||
AggregateFunctionPercentileApprox>(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "percentile_approx"; }
|
||||
|
||||
@ -358,7 +357,7 @@ class AggregateFunctionPercentile final
|
||||
public:
|
||||
AggregateFunctionPercentile(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<PercentileState, AggregateFunctionPercentile>(
|
||||
argument_types_, {}) {}
|
||||
argument_types_) {}
|
||||
|
||||
String get_name() const override { return "percentile"; }
|
||||
|
||||
@ -401,7 +400,7 @@ class AggregateFunctionPercentileArray final
|
||||
public:
|
||||
AggregateFunctionPercentileArray(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<PercentileState, AggregateFunctionPercentileArray>(
|
||||
argument_types_, {}) {}
|
||||
argument_types_) {}
|
||||
|
||||
String get_name() const override { return "percentile_array"; }
|
||||
|
||||
|
||||
@ -91,12 +91,12 @@ public:
|
||||
|
||||
AggregateFunctionProduct(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionProduct<T, TResult, Data>>(
|
||||
argument_types_, {}),
|
||||
argument_types_),
|
||||
scale(0) {}
|
||||
|
||||
AggregateFunctionProduct(const IDataType& data_type, const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionProduct<T, TResult, Data>>(
|
||||
argument_types_, {}),
|
||||
argument_types_),
|
||||
scale(get_decimal_scale(data_type)) {}
|
||||
|
||||
DataTypePtr get_return_type() const override {
|
||||
|
||||
@ -198,7 +198,7 @@ class ReaderFunctionData final
|
||||
: public IAggregateFunctionDataHelper<Data, ReaderFunctionData<Data>> {
|
||||
public:
|
||||
ReaderFunctionData(const DataTypes& argument_types)
|
||||
: IAggregateFunctionDataHelper<Data, ReaderFunctionData<Data>>(argument_types, {}),
|
||||
: IAggregateFunctionDataHelper<Data, ReaderFunctionData<Data>>(argument_types),
|
||||
_argument_type(argument_types[0]) {}
|
||||
|
||||
String get_name() const override { return Data::name(); }
|
||||
@ -238,8 +238,7 @@ private:
|
||||
template <template <typename> class AggregateFunctionTemplate, template <typename> class Impl,
|
||||
bool result_is_nullable, bool arg_is_nullable, bool is_copy = false>
|
||||
static IAggregateFunction* create_function_single_value(const String& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters) {
|
||||
const DataTypes& argument_types) {
|
||||
auto type = remove_nullable(argument_types[0]);
|
||||
WhichDataType which(*type);
|
||||
|
||||
@ -255,27 +254,25 @@ static IAggregateFunction* create_function_single_value(const String& name,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#define CREATE_READER_FUNCTION_WITH_NAME_AND_DATA(CREATE_FUNCTION_NAME, FUNCTION_DATA) \
|
||||
template <bool is_copy> \
|
||||
AggregateFunctionPtr CREATE_FUNCTION_NAME(const std::string& name, \
|
||||
const DataTypes& argument_types, \
|
||||
const Array& parameters, bool result_is_nullable) { \
|
||||
const bool arg_is_nullable = argument_types[0]->is_nullable(); \
|
||||
AggregateFunctionPtr res = nullptr; \
|
||||
std::visit( \
|
||||
[&](auto result_is_nullable, auto arg_is_nullable) { \
|
||||
res = AggregateFunctionPtr( \
|
||||
create_function_single_value<ReaderFunctionData, FUNCTION_DATA, \
|
||||
result_is_nullable, arg_is_nullable, \
|
||||
is_copy>(name, argument_types, \
|
||||
parameters)); \
|
||||
}, \
|
||||
make_bool_variant(result_is_nullable), make_bool_variant(arg_is_nullable)); \
|
||||
if (!res) { \
|
||||
LOG(WARNING) << " failed in create_aggregate_function_" << name \
|
||||
<< " and type is: " << argument_types[0]->get_name(); \
|
||||
} \
|
||||
return res; \
|
||||
#define CREATE_READER_FUNCTION_WITH_NAME_AND_DATA(CREATE_FUNCTION_NAME, FUNCTION_DATA) \
|
||||
template <bool is_copy> \
|
||||
AggregateFunctionPtr CREATE_FUNCTION_NAME( \
|
||||
const std::string& name, const DataTypes& argument_types, bool result_is_nullable) { \
|
||||
const bool arg_is_nullable = argument_types[0]->is_nullable(); \
|
||||
AggregateFunctionPtr res = nullptr; \
|
||||
std::visit( \
|
||||
[&](auto result_is_nullable, auto arg_is_nullable) { \
|
||||
res = AggregateFunctionPtr( \
|
||||
create_function_single_value<ReaderFunctionData, FUNCTION_DATA, \
|
||||
result_is_nullable, arg_is_nullable, \
|
||||
is_copy>(name, argument_types)); \
|
||||
}, \
|
||||
make_bool_variant(result_is_nullable), make_bool_variant(arg_is_nullable)); \
|
||||
if (!res) { \
|
||||
LOG(WARNING) << " failed in create_aggregate_function_" << name \
|
||||
<< " and type is: " << argument_types[0]->get_name(); \
|
||||
} \
|
||||
return res; \
|
||||
}
|
||||
|
||||
CREATE_READER_FUNCTION_WITH_NAME_AND_DATA(create_aggregate_function_first, ReaderFunctionFirstData);
|
||||
|
||||
@ -25,7 +25,6 @@ namespace doris::vectorized {
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_retention(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return std::make_shared<AggregateFunctionRetention>(argument_types);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ class AggregateFunctionRetention
|
||||
public:
|
||||
AggregateFunctionRetention(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<RetentionState, AggregateFunctionRetention>(
|
||||
argument_types_, {}) {}
|
||||
argument_types_) {}
|
||||
|
||||
String get_name() const override { return "retention"; }
|
||||
|
||||
|
||||
@ -345,16 +345,14 @@ public:
|
||||
class AggregateRpcUdaf final
|
||||
: public IAggregateFunctionDataHelper<AggregateRpcUdafData, AggregateRpcUdaf> {
|
||||
public:
|
||||
AggregateRpcUdaf(const TFunction& fn, const DataTypes& argument_types, const Array& parameters,
|
||||
AggregateRpcUdaf(const TFunction& fn, const DataTypes& argument_types,
|
||||
const DataTypePtr& return_type)
|
||||
: IAggregateFunctionDataHelper(argument_types, parameters),
|
||||
_fn(fn),
|
||||
_return_type(return_type) {}
|
||||
: IAggregateFunctionDataHelper(argument_types), _fn(fn), _return_type(return_type) {}
|
||||
~AggregateRpcUdaf() = default;
|
||||
|
||||
static AggregateFunctionPtr create(const TFunction& fn, const DataTypes& argument_types,
|
||||
const Array& parameters, const DataTypePtr& return_type) {
|
||||
return std::make_shared<AggregateRpcUdaf>(fn, argument_types, parameters, return_type);
|
||||
const DataTypePtr& return_type) {
|
||||
return std::make_shared<AggregateRpcUdaf>(fn, argument_types, return_type);
|
||||
}
|
||||
|
||||
void create(AggregateDataPtr __restrict place) const override {
|
||||
|
||||
@ -27,7 +27,6 @@ namespace doris::vectorized {
|
||||
template <template <typename, typename> typename AggregateFunction>
|
||||
AggregateFunctionPtr create_aggregate_function_sequence_base(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
const auto arg_count = argument_types.size();
|
||||
|
||||
|
||||
@ -566,7 +566,7 @@ public:
|
||||
AggregateFunctionSequenceBase(const DataTypes& arguments)
|
||||
: IAggregateFunctionDataHelper<
|
||||
AggregateFunctionSequenceMatchData<DateValueType, NativeType, Derived>,
|
||||
Derived>(arguments, {}) {
|
||||
Derived>(arguments) {
|
||||
arg_count = arguments.size();
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,6 @@ AggregateFunctionSimpleFactory& AggregateFunctionSimpleFactory::instance() {
|
||||
register_aggregate_function_collect_list(instance);
|
||||
register_aggregate_function_sequence_match(instance);
|
||||
register_aggregate_function_avg_weighted(instance);
|
||||
register_aggregate_function_avg_weighted(instance);
|
||||
register_aggregate_function_histogram(instance);
|
||||
|
||||
// if you only register function with no nullable, and wants to add nullable automatically, you should place function above this line
|
||||
|
||||
@ -33,8 +33,8 @@
|
||||
namespace doris::vectorized {
|
||||
using DataTypePtr = std::shared_ptr<const IDataType>;
|
||||
using DataTypes = std::vector<DataTypePtr>;
|
||||
using AggregateFunctionCreator = std::function<AggregateFunctionPtr(
|
||||
const std::string&, const DataTypes&, const Array&, const bool)>;
|
||||
using AggregateFunctionCreator =
|
||||
std::function<AggregateFunctionPtr(const std::string&, const DataTypes&, const bool)>;
|
||||
|
||||
class AggregateFunctionSimpleFactory {
|
||||
public:
|
||||
@ -73,7 +73,7 @@ public:
|
||||
}
|
||||
|
||||
AggregateFunctionPtr get(const std::string& name, const DataTypes& argument_types,
|
||||
const Array& parameters, const bool result_is_nullable = false) {
|
||||
const bool result_is_nullable = false) {
|
||||
bool nullable = false;
|
||||
for (const auto& type : argument_types) {
|
||||
if (type->is_nullable()) {
|
||||
@ -90,11 +90,11 @@ public:
|
||||
return nullable_aggregate_functions.find(name_str) == nullable_aggregate_functions.end()
|
||||
? nullptr
|
||||
: nullable_aggregate_functions[name_str](name_str, argument_types,
|
||||
parameters, result_is_nullable);
|
||||
result_is_nullable);
|
||||
} else {
|
||||
return aggregate_functions.find(name_str) == aggregate_functions.end()
|
||||
? nullptr
|
||||
: aggregate_functions[name_str](name_str, argument_types, parameters,
|
||||
: aggregate_functions[name_str](name_str, argument_types,
|
||||
result_is_nullable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,8 +105,7 @@ private:
|
||||
public:
|
||||
AggregateFunctionSort(const AggregateFunctionPtr& nested_func, const DataTypes& arguments,
|
||||
const SortDescription& sort_desc, const RuntimeState* state)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionSort>(
|
||||
arguments, nested_func->get_parameters()),
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionSort>(arguments),
|
||||
_nested_func(nested_func),
|
||||
_arguments(arguments),
|
||||
_sort_desc(sort_desc),
|
||||
|
||||
@ -27,8 +27,7 @@ template <template <typename, bool> class AggregateFunctionTemplate,
|
||||
template <typename> class NameData, template <typename, typename> class Data,
|
||||
bool is_stddev, bool is_nullable = false>
|
||||
static IAggregateFunction* create_function_single_value(const String& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters) {
|
||||
const DataTypes& argument_types) {
|
||||
auto type = argument_types[0].get();
|
||||
if (type->is_nullable()) {
|
||||
type = assert_cast<const DataTypeNullable*>(type)->get_nested_type().get();
|
||||
@ -70,41 +69,37 @@ static IAggregateFunction* create_function_single_value(const String& name,
|
||||
template <bool is_stddev, bool is_nullable>
|
||||
AggregateFunctionPtr create_aggregate_function_variance_samp(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(
|
||||
create_function_single_value<AggregateFunctionSamp, VarianceSampName, SampData,
|
||||
is_stddev, is_nullable>(name, argument_types, parameters));
|
||||
is_stddev, is_nullable>(name, argument_types));
|
||||
}
|
||||
|
||||
template <bool is_stddev, bool is_nullable>
|
||||
AggregateFunctionPtr create_aggregate_function_stddev_samp(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(
|
||||
create_function_single_value<AggregateFunctionSamp, StddevSampName, SampData, is_stddev,
|
||||
is_nullable>(name, argument_types, parameters));
|
||||
is_nullable>(name, argument_types));
|
||||
}
|
||||
|
||||
template <bool is_stddev>
|
||||
AggregateFunctionPtr create_aggregate_function_variance_pop(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(
|
||||
create_function_single_value<AggregateFunctionPop, VarianceName, PopData, is_stddev>(
|
||||
name, argument_types, parameters));
|
||||
name, argument_types));
|
||||
}
|
||||
|
||||
template <bool is_stddev>
|
||||
AggregateFunctionPtr create_aggregate_function_stddev_pop(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return AggregateFunctionPtr(
|
||||
create_function_single_value<AggregateFunctionPop, StddevName, PopData, is_stddev>(
|
||||
name, argument_types, parameters));
|
||||
name, argument_types));
|
||||
}
|
||||
|
||||
void register_aggregate_function_stddev_variance_pop(AggregateFunctionSimpleFactory& factory) {
|
||||
|
||||
@ -258,7 +258,7 @@ public:
|
||||
AggregateFunctionSampVariance(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<
|
||||
Data, AggregateFunctionSampVariance<is_pop, Data, is_nullable>>(
|
||||
argument_types_, {}) {}
|
||||
argument_types_) {}
|
||||
|
||||
String get_name() const override { return Data::name(); }
|
||||
|
||||
|
||||
@ -44,18 +44,16 @@ using AggregateFunctionSumSimple = typename SumSimple<T>::Function;
|
||||
template <template <typename> class Function>
|
||||
AggregateFunctionPtr create_aggregate_function_sum(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
AggregateFunctionPtr res;
|
||||
DataTypePtr data_type = argument_types[0];
|
||||
if (data_type->is_nullable()) {
|
||||
auto no_null_argument_types = remove_nullable(argument_types);
|
||||
if (is_decimal(no_null_argument_types[0])) {
|
||||
res.reset(create_with_decimal_type_null<Function>(no_null_argument_types, parameters,
|
||||
*no_null_argument_types[0],
|
||||
no_null_argument_types));
|
||||
res.reset(create_with_decimal_type_null<Function>(
|
||||
no_null_argument_types, *no_null_argument_types[0], no_null_argument_types));
|
||||
} else {
|
||||
res.reset(create_with_numeric_type_null<Function>(no_null_argument_types, parameters,
|
||||
res.reset(create_with_numeric_type_null<Function>(no_null_argument_types,
|
||||
no_null_argument_types));
|
||||
}
|
||||
} else {
|
||||
@ -86,10 +84,9 @@ using AggregateFunctionSumSimpleReader = typename SumSimpleReader<T>::Function;
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_sum_reader(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
return create_aggregate_function_sum<AggregateFunctionSumSimpleReader>(
|
||||
name, argument_types, parameters, result_is_nullable);
|
||||
return create_aggregate_function_sum<AggregateFunctionSumSimpleReader>(name, argument_types,
|
||||
result_is_nullable);
|
||||
}
|
||||
|
||||
void register_aggregate_function_sum(AggregateFunctionSimpleFactory& factory) {
|
||||
|
||||
@ -58,12 +58,12 @@ public:
|
||||
|
||||
AggregateFunctionSum(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionSum<T, TResult, Data>>(
|
||||
argument_types_, {}),
|
||||
argument_types_),
|
||||
scale(0) {}
|
||||
|
||||
AggregateFunctionSum(const IDataType& data_type, const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionSum<T, TResult, Data>>(
|
||||
argument_types_, {}),
|
||||
argument_types_),
|
||||
scale(get_decimal_scale(data_type)) {}
|
||||
|
||||
DataTypePtr get_return_type() const override {
|
||||
@ -160,7 +160,6 @@ private:
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_sum_reader(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable);
|
||||
|
||||
} // namespace doris::vectorized
|
||||
|
||||
@ -23,7 +23,6 @@ namespace doris::vectorized {
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_topn(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
if (argument_types.size() == 2) {
|
||||
return AggregateFunctionPtr(
|
||||
@ -83,7 +82,6 @@ AggregateFunctionPtr create_topn_array(const DataTypes& argument_types) {
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_topn_array(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
bool has_default_param = (argument_types.size() == 3);
|
||||
if (has_default_param) {
|
||||
@ -95,7 +93,6 @@ AggregateFunctionPtr create_aggregate_function_topn_array(const std::string& nam
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_topn_weighted(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
bool has_default_param = (argument_types.size() == 4);
|
||||
if (has_default_param) {
|
||||
|
||||
@ -263,8 +263,7 @@ class AggregateFunctionTopNBase
|
||||
public:
|
||||
AggregateFunctionTopNBase(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<AggregateFunctionTopNData<T>,
|
||||
AggregateFunctionTopNBase<Impl, T>>(argument_types_,
|
||||
{}) {}
|
||||
AggregateFunctionTopNBase<Impl, T>>(argument_types_) {}
|
||||
|
||||
void add(AggregateDataPtr __restrict place, const IColumn** columns, size_t row_num,
|
||||
Arena*) const override {
|
||||
|
||||
@ -31,10 +31,7 @@ namespace doris::vectorized {
|
||||
template <template <typename> class Data, typename DataForVariadic>
|
||||
AggregateFunctionPtr create_aggregate_function_uniq(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& params,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, params);
|
||||
|
||||
if (argument_types.empty()) {
|
||||
LOG(WARNING) << "Incorrect number of arguments for aggregate function " << name;
|
||||
return nullptr;
|
||||
|
||||
@ -90,8 +90,7 @@ class AggregateFunctionUniq final
|
||||
public:
|
||||
using KeyType = std::conditional_t<std::is_same_v<T, String>, UInt128, T>;
|
||||
AggregateFunctionUniq(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionUniq<T, Data>>(argument_types_,
|
||||
{}) {}
|
||||
: IAggregateFunctionDataHelper<Data, AggregateFunctionUniq<T, Data>>(argument_types_) {}
|
||||
|
||||
String get_name() const override { return Data::get_name(); }
|
||||
|
||||
|
||||
@ -28,46 +28,35 @@ namespace doris::vectorized {
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_dense_rank(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
|
||||
return std::make_shared<WindowFunctionDenseRank>(argument_types);
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_rank(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
|
||||
return std::make_shared<WindowFunctionRank>(argument_types);
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_row_number(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_no_parameters(name, parameters);
|
||||
|
||||
return std::make_shared<WindowFunctionRowNumber>(argument_types);
|
||||
}
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_ntile(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
assert_unary(name, argument_types);
|
||||
|
||||
return std::make_shared<WindowFunctionNTile>(argument_types, parameters);
|
||||
return std::make_shared<WindowFunctionNTile>(argument_types);
|
||||
}
|
||||
|
||||
template <template <typename> class AggregateFunctionTemplate,
|
||||
template <typename ColVecType, bool, bool> class Data, template <typename> class Impl,
|
||||
bool result_is_nullable, bool arg_is_nullable>
|
||||
static IAggregateFunction* create_function_lead_lag_first_last(const String& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters) {
|
||||
const DataTypes& argument_types) {
|
||||
auto type = remove_nullable(argument_types[0]);
|
||||
WhichDataType which(*type);
|
||||
|
||||
@ -85,9 +74,9 @@ static IAggregateFunction* create_function_lead_lag_first_last(const String& nam
|
||||
|
||||
#define CREATE_WINDOW_FUNCTION_WITH_NAME_AND_DATA(CREATE_FUNCTION_NAME, FUNCTION_DATA, \
|
||||
FUNCTION_IMPL) \
|
||||
AggregateFunctionPtr CREATE_FUNCTION_NAME( \
|
||||
const std::string& name, const DataTypes& argument_types, const Array& parameters, \
|
||||
const bool result_is_nullable) { \
|
||||
AggregateFunctionPtr CREATE_FUNCTION_NAME(const std::string& name, \
|
||||
const DataTypes& argument_types, \
|
||||
const bool result_is_nullable) { \
|
||||
const bool arg_is_nullable = argument_types[0]->is_nullable(); \
|
||||
AggregateFunctionPtr res = nullptr; \
|
||||
\
|
||||
@ -96,8 +85,8 @@ static IAggregateFunction* create_function_lead_lag_first_last(const String& nam
|
||||
res = AggregateFunctionPtr( \
|
||||
create_function_lead_lag_first_last<WindowFunctionData, FUNCTION_DATA, \
|
||||
FUNCTION_IMPL, result_is_nullable, \
|
||||
arg_is_nullable>( \
|
||||
name, argument_types, parameters)); \
|
||||
arg_is_nullable>(name, \
|
||||
argument_types)); \
|
||||
}, \
|
||||
make_bool_variant(result_is_nullable), make_bool_variant(arg_is_nullable)); \
|
||||
if (!res) { \
|
||||
|
||||
@ -41,7 +41,7 @@ class WindowFunctionRowNumber final
|
||||
: public IAggregateFunctionDataHelper<RowNumberData, WindowFunctionRowNumber> {
|
||||
public:
|
||||
WindowFunctionRowNumber(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper(argument_types_, {}) {}
|
||||
: IAggregateFunctionDataHelper(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "row_number"; }
|
||||
|
||||
@ -79,7 +79,7 @@ struct RankData {
|
||||
class WindowFunctionRank final : public IAggregateFunctionDataHelper<RankData, WindowFunctionRank> {
|
||||
public:
|
||||
WindowFunctionRank(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper(argument_types_, {}) {}
|
||||
: IAggregateFunctionDataHelper(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "rank"; }
|
||||
|
||||
@ -123,7 +123,7 @@ class WindowFunctionDenseRank final
|
||||
: public IAggregateFunctionDataHelper<DenseRankData, WindowFunctionDenseRank> {
|
||||
public:
|
||||
WindowFunctionDenseRank(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper(argument_types_, {}) {}
|
||||
: IAggregateFunctionDataHelper(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "dense_rank"; }
|
||||
|
||||
@ -164,8 +164,8 @@ struct NTileData {
|
||||
class WindowFunctionNTile final
|
||||
: public IAggregateFunctionDataHelper<NTileData, WindowFunctionNTile> {
|
||||
public:
|
||||
WindowFunctionNTile(const DataTypes& argument_types_, const Array& parameters)
|
||||
: IAggregateFunctionDataHelper(argument_types_, parameters) {}
|
||||
WindowFunctionNTile(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "ntile"; }
|
||||
|
||||
@ -370,7 +370,7 @@ class WindowFunctionData final
|
||||
: public IAggregateFunctionDataHelper<Data, WindowFunctionData<Data>> {
|
||||
public:
|
||||
WindowFunctionData(const DataTypes& argument_types)
|
||||
: IAggregateFunctionDataHelper<Data, WindowFunctionData<Data>>(argument_types, {}),
|
||||
: IAggregateFunctionDataHelper<Data, WindowFunctionData<Data>>(argument_types),
|
||||
_argument_type(argument_types[0]) {}
|
||||
|
||||
String get_name() const override { return Data::name(); }
|
||||
|
||||
@ -24,7 +24,6 @@ namespace doris::vectorized {
|
||||
|
||||
AggregateFunctionPtr create_aggregate_function_window_funnel(const std::string& name,
|
||||
const DataTypes& argument_types,
|
||||
const Array& parameters,
|
||||
const bool result_is_nullable) {
|
||||
if (argument_types.size() < 3) {
|
||||
LOG(WARNING) << "window_funnel's argument less than 3.";
|
||||
|
||||
@ -168,8 +168,7 @@ public:
|
||||
AggregateFunctionWindowFunnel(const DataTypes& argument_types_)
|
||||
: IAggregateFunctionDataHelper<
|
||||
WindowFunnelState<DateValueType, NativeType>,
|
||||
AggregateFunctionWindowFunnel<DateValueType, NativeType>>(argument_types_,
|
||||
{}) {}
|
||||
AggregateFunctionWindowFunnel<DateValueType, NativeType>>(argument_types_) {}
|
||||
|
||||
String get_name() const override { return "window_funnel"; }
|
||||
|
||||
|
||||
@ -26,10 +26,6 @@
|
||||
|
||||
namespace doris::vectorized {
|
||||
|
||||
inline void assert_no_parameters(const std::string& name, const Array& parameters) {
|
||||
CHECK(parameters.empty()) << fmt::format("Aggregate function {} cannot have parameters", name);
|
||||
}
|
||||
|
||||
inline void assert_unary(const std::string& name, const DataTypes& argument_types) {
|
||||
CHECK_EQ(argument_types.size(), 1)
|
||||
<< fmt::format("Aggregate function {} require single argument", name);
|
||||
|
||||
@ -62,13 +62,13 @@ static IAggregateFunction* create_with_numeric_type(const IDataType& argument_ty
|
||||
|
||||
template <template <typename> class AggregateFunctionTemplate, typename... TArgs>
|
||||
static IAggregateFunction* create_with_numeric_type_null(const DataTypes& argument_types,
|
||||
const Array& params, TArgs&&... args) {
|
||||
TArgs&&... args) {
|
||||
WhichDataType which(argument_types[0]);
|
||||
#define DISPATCH(TYPE) \
|
||||
if (which.idx == TypeIndex::TYPE) \
|
||||
return new AggregateFunctionNullUnaryInline<AggregateFunctionTemplate<TYPE>, true>( \
|
||||
new AggregateFunctionTemplate<TYPE>(std::forward<TArgs>(args)...), argument_types, \
|
||||
params);
|
||||
#define DISPATCH(TYPE) \
|
||||
if (which.idx == TypeIndex::TYPE) \
|
||||
return new AggregateFunctionNullUnaryInline<AggregateFunctionTemplate<TYPE>, true>( \
|
||||
new AggregateFunctionTemplate<TYPE>(std::forward<TArgs>(args)...), \
|
||||
argument_types);
|
||||
FOR_NUMERIC_TYPES(DISPATCH)
|
||||
#undef DISPATCH
|
||||
return nullptr;
|
||||
@ -140,13 +140,13 @@ static IAggregateFunction* create_with_decimal_type(const IDataType& argument_ty
|
||||
|
||||
template <template <typename> class AggregateFunctionTemplate, typename... TArgs>
|
||||
static IAggregateFunction* create_with_decimal_type_null(const DataTypes& argument_types,
|
||||
const Array& params, TArgs&&... args) {
|
||||
TArgs&&... args) {
|
||||
WhichDataType which(argument_types[0]);
|
||||
#define DISPATCH(TYPE) \
|
||||
if (which.idx == TypeIndex::TYPE) \
|
||||
return new AggregateFunctionNullUnaryInline<AggregateFunctionTemplate<TYPE>, true>( \
|
||||
new AggregateFunctionTemplate<TYPE>(std::forward<TArgs>(args)...), argument_types, \
|
||||
params);
|
||||
#define DISPATCH(TYPE) \
|
||||
if (which.idx == TypeIndex::TYPE) \
|
||||
return new AggregateFunctionNullUnaryInline<AggregateFunctionTemplate<TYPE>, true>( \
|
||||
new AggregateFunctionTemplate<TYPE>(std::forward<TArgs>(args)...), \
|
||||
argument_types);
|
||||
FOR_DECIMAL_TYPES(DISPATCH)
|
||||
#undef DISPATCH
|
||||
return nullptr;
|
||||
|
||||
@ -114,7 +114,7 @@ Status AggFnEvaluator::prepare(RuntimeState* state, const RowDescriptor& desc,
|
||||
|
||||
if (_fn.binary_type == TFunctionBinaryType::JAVA_UDF) {
|
||||
if (config::enable_java_support) {
|
||||
_function = AggregateJavaUdaf::create(_fn, argument_types, {}, _data_type);
|
||||
_function = AggregateJavaUdaf::create(_fn, argument_types, _data_type);
|
||||
RETURN_IF_ERROR(static_cast<AggregateJavaUdaf*>(_function.get())->check_udaf(_fn));
|
||||
} else {
|
||||
return Status::InternalError(
|
||||
@ -122,10 +122,10 @@ Status AggFnEvaluator::prepare(RuntimeState* state, const RowDescriptor& desc,
|
||||
"true and restart be.");
|
||||
}
|
||||
} else if (_fn.binary_type == TFunctionBinaryType::RPC) {
|
||||
_function = AggregateRpcUdaf::create(_fn, argument_types, {}, _data_type);
|
||||
_function = AggregateRpcUdaf::create(_fn, argument_types, _data_type);
|
||||
} else {
|
||||
_function = AggregateFunctionSimpleFactory::instance().get(
|
||||
_fn.name.function_name, argument_types, {}, _data_type->is_nullable());
|
||||
_fn.name.function_name, argument_types, _data_type->is_nullable());
|
||||
}
|
||||
if (_function == nullptr) {
|
||||
return Status::InternalError("Agg Function {} is not implemented", _fn.signature);
|
||||
|
||||
@ -130,7 +130,7 @@ struct AggregateFunction {
|
||||
|
||||
AggregateFunctionPtr function;
|
||||
function.reset(new AggregateFunctionNullUnary<true>(nested_function,
|
||||
{make_nullable(data_type_ptr)}, {}));
|
||||
{make_nullable(data_type_ptr)}));
|
||||
return function;
|
||||
}
|
||||
};
|
||||
@ -238,11 +238,11 @@ struct AggregateFunction<AggregateFunctionImpl<AggregateOperation::MIN>> {
|
||||
static auto create(const DataTypePtr& data_type_ptr) -> AggregateFunctionPtr {
|
||||
DataTypes data_types = {remove_nullable(data_type_ptr)};
|
||||
auto nested_function = AggregateFunctionPtr(
|
||||
create_aggregate_function_min(NameArrayMin::name, data_types, {}, false));
|
||||
create_aggregate_function_min(NameArrayMin::name, data_types, false));
|
||||
|
||||
AggregateFunctionPtr function;
|
||||
function.reset(new AggregateFunctionNullUnary<true>(nested_function,
|
||||
{make_nullable(data_type_ptr)}, {}));
|
||||
{make_nullable(data_type_ptr)}));
|
||||
return function;
|
||||
}
|
||||
};
|
||||
@ -256,11 +256,11 @@ struct AggregateFunction<AggregateFunctionImpl<AggregateOperation::MAX>> {
|
||||
static auto create(const DataTypePtr& data_type_ptr) -> AggregateFunctionPtr {
|
||||
DataTypes data_types = {remove_nullable(data_type_ptr)};
|
||||
auto nested_function = AggregateFunctionPtr(
|
||||
create_aggregate_function_max(NameArrayMax::name, data_types, {}, false));
|
||||
create_aggregate_function_max(NameArrayMax::name, data_types, false));
|
||||
|
||||
AggregateFunctionPtr function;
|
||||
function.reset(new AggregateFunctionNullUnary<true>(nested_function,
|
||||
{make_nullable(data_type_ptr)}, {}));
|
||||
{make_nullable(data_type_ptr)}));
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
@ -74,9 +74,8 @@ public:
|
||||
void test_agg_collect(const std::string& fn_name, size_t input_nums = 0) {
|
||||
DataTypes data_types = {(DataTypePtr)std::make_shared<DataType>()};
|
||||
LOG(INFO) << "test_agg_collect for " << fn_name << "(" << data_types[0]->get_name() << ")";
|
||||
Array array;
|
||||
AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
|
||||
auto agg_function = factory.get(fn_name, data_types, array);
|
||||
auto agg_function = factory.get(fn_name, data_types);
|
||||
EXPECT_NE(agg_function, nullptr);
|
||||
|
||||
std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
|
||||
|
||||
@ -108,9 +108,8 @@ public:
|
||||
LOG(INFO) << "test_agg_histogram for type"
|
||||
<< "(" << data_types[0]->get_name() << ")";
|
||||
|
||||
Array array;
|
||||
AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
|
||||
auto agg_function = factory.get("histogram", data_types, array);
|
||||
auto agg_function = factory.get("histogram", data_types);
|
||||
EXPECT_NE(agg_function, nullptr);
|
||||
|
||||
std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
|
||||
|
||||
@ -67,8 +67,7 @@ TEST_P(AggMinMaxByTest, min_max_by_test) {
|
||||
DataTypes data_types = {std::make_shared<DataTypeInt32>(),
|
||||
i == 0 ? (DataTypePtr)std::make_shared<DataTypeInt32>()
|
||||
: (DataTypePtr)std::make_shared<DataTypeString>()};
|
||||
Array array;
|
||||
auto agg_function = factory.get(min_max_by_type, data_types, array);
|
||||
auto agg_function = factory.get(min_max_by_type, data_types);
|
||||
std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
|
||||
AggregateDataPtr place = memory.get();
|
||||
agg_function->create(place);
|
||||
|
||||
@ -49,8 +49,7 @@ TEST_P(AggMinMaxTest, min_max_test) {
|
||||
AggregateFunctionSimpleFactory factory;
|
||||
register_aggregate_function_minmax(factory);
|
||||
DataTypes data_types = {std::make_shared<DataTypeInt32>()};
|
||||
Array array;
|
||||
auto agg_function = factory.get(min_max_type, data_types, array);
|
||||
auto agg_function = factory.get(min_max_type, data_types);
|
||||
std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
|
||||
AggregateDataPtr place = memory.get();
|
||||
agg_function->create(place);
|
||||
@ -82,8 +81,7 @@ TEST_P(AggMinMaxTest, min_max_decimal_test) {
|
||||
AggregateFunctionSimpleFactory factory;
|
||||
register_aggregate_function_minmax(factory);
|
||||
DataTypes data_types = {data_type};
|
||||
Array array;
|
||||
auto agg_function = factory.get(min_max_type, data_types, array);
|
||||
auto agg_function = factory.get(min_max_type, data_types);
|
||||
std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
|
||||
AggregateDataPtr place = memory.get();
|
||||
agg_function->create(place);
|
||||
@ -130,8 +128,7 @@ TEST_P(AggMinMaxTest, min_max_string_test) {
|
||||
AggregateFunctionSimpleFactory factory;
|
||||
register_aggregate_function_minmax(factory);
|
||||
DataTypes data_types = {std::make_shared<DataTypeString>()};
|
||||
Array array;
|
||||
auto agg_function = factory.get(min_max_type, data_types, array);
|
||||
auto agg_function = factory.get(min_max_type, data_types);
|
||||
std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
|
||||
AggregateDataPtr place = memory.get();
|
||||
agg_function->create(place);
|
||||
|
||||
@ -44,8 +44,7 @@ TEST(AggTest, basic_test) {
|
||||
register_aggregate_function_sum(factory);
|
||||
DataTypePtr data_type(std::make_shared<DataTypeInt32>());
|
||||
DataTypes data_types = {data_type};
|
||||
Array array;
|
||||
auto agg_function = factory.get("sum", data_types, array);
|
||||
auto agg_function = factory.get("sum", data_types);
|
||||
std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
|
||||
AggregateDataPtr place = memory.get();
|
||||
agg_function->create(place);
|
||||
@ -76,9 +75,8 @@ TEST(AggTest, topn_test) {
|
||||
AggregateFunctionSimpleFactory factory;
|
||||
register_aggregate_function_topn(factory);
|
||||
DataTypes data_types = {std::make_shared<DataTypeString>(), std::make_shared<DataTypeInt32>()};
|
||||
Array array;
|
||||
|
||||
auto agg_function = factory.get("topn", data_types, array);
|
||||
auto agg_function = factory.get("topn", data_types);
|
||||
std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
|
||||
AggregateDataPtr place = memory.get();
|
||||
agg_function->create(place);
|
||||
|
||||
@ -46,8 +46,7 @@ public:
|
||||
std::make_shared<DataTypeUInt8>(),
|
||||
std::make_shared<DataTypeUInt8>(),
|
||||
};
|
||||
Array array;
|
||||
agg_function = factory.get("retention", data_types, array, false);
|
||||
agg_function = factory.get("retention", data_types, false);
|
||||
EXPECT_NE(agg_function, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -43,10 +43,9 @@ public:
|
||||
std::make_shared<DataTypeString>(), std::make_shared<DataTypeDateTime>(),
|
||||
std::make_shared<DataTypeUInt8>(), std::make_shared<DataTypeUInt8>(),
|
||||
std::make_shared<DataTypeUInt8>()};
|
||||
Array array;
|
||||
agg_function_sequence_match = factory.get("sequence_match", data_types, array, false);
|
||||
agg_function_sequence_match = factory.get("sequence_match", data_types, false);
|
||||
EXPECT_NE(agg_function_sequence_match, nullptr);
|
||||
agg_function_sequence_count = factory.get("sequence_count", data_types, array, false);
|
||||
agg_function_sequence_count = factory.get("sequence_count", data_types, false);
|
||||
EXPECT_NE(agg_function_sequence_count, nullptr);
|
||||
}
|
||||
|
||||
@ -180,8 +179,7 @@ TEST_F(VSequenceMatchTest, testCountSerialize) {
|
||||
DataTypes data_types = {std::make_shared<DataTypeString>(),
|
||||
std::make_shared<DataTypeDateTime>(), std::make_shared<DataTypeUInt8>(),
|
||||
std::make_shared<DataTypeUInt8>()};
|
||||
Array array;
|
||||
agg_function_sequence_count = factory.get("sequence_count", data_types, array, false);
|
||||
agg_function_sequence_count = factory.get("sequence_count", data_types, false);
|
||||
EXPECT_NE(agg_function_sequence_count, nullptr);
|
||||
|
||||
const int NUM_CONDS = 4;
|
||||
@ -246,8 +244,7 @@ TEST_F(VSequenceMatchTest, testMatchReverseSortedSerializeMerge) {
|
||||
DataTypes data_types = {std::make_shared<DataTypeString>(),
|
||||
std::make_shared<DataTypeDateTime>(), std::make_shared<DataTypeUInt8>(),
|
||||
std::make_shared<DataTypeUInt8>()};
|
||||
Array array;
|
||||
agg_function_sequence_match = factory.get("sequence_match", data_types, array, false);
|
||||
agg_function_sequence_match = factory.get("sequence_match", data_types, false);
|
||||
EXPECT_NE(agg_function_sequence_match, nullptr);
|
||||
|
||||
const int NUM_CONDS = 2;
|
||||
@ -336,8 +333,7 @@ TEST_F(VSequenceMatchTest, testCountReverseSortedSerializeMerge) {
|
||||
DataTypes data_types = {std::make_shared<DataTypeString>(),
|
||||
std::make_shared<DataTypeDateTime>(), std::make_shared<DataTypeUInt8>(),
|
||||
std::make_shared<DataTypeUInt8>()};
|
||||
Array array;
|
||||
agg_function_sequence_count = factory.get("sequence_count", data_types, array, false);
|
||||
agg_function_sequence_count = factory.get("sequence_count", data_types, false);
|
||||
EXPECT_NE(agg_function_sequence_count, nullptr);
|
||||
|
||||
const int NUM_CONDS = 2;
|
||||
|
||||
@ -42,8 +42,7 @@ public:
|
||||
std::make_shared<DataTypeDateTime>(), std::make_shared<DataTypeUInt8>(),
|
||||
std::make_shared<DataTypeUInt8>(), std::make_shared<DataTypeUInt8>(),
|
||||
std::make_shared<DataTypeUInt8>()};
|
||||
Array array;
|
||||
agg_function = factory.get("window_funnel", data_types, array, false);
|
||||
agg_function = factory.get("window_funnel", data_types, false);
|
||||
EXPECT_NE(agg_function, nullptr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user