Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ AggregateFunctionPtr create_aggregate_function_approx_count_distinct(
return creator_with_type_list<
TYPE_BOOLEAN, TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT, TYPE_LARGEINT,
TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMAL32, TYPE_DECIMAL64, TYPE_DECIMAL128I,
TYPE_DECIMALV2, TYPE_DECIMAL256, TYPE_VARCHAR, TYPE_DATEV2, TYPE_DATETIMEV2, TYPE_IPV4,
TYPE_DECIMAL256, TYPE_VARCHAR, TYPE_DATEV2, TYPE_DATETIMEV2, TYPE_IPV4,
TYPE_IPV6>::create<AggregateFunctionApproxCountDistinct>(argument_types,
result_is_nullable, attr);
}
Expand Down
15 changes: 9 additions & 6 deletions be/src/vec/aggregate_functions/aggregate_function_bit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,25 @@

#include "vec/aggregate_functions/aggregate_function_bit.h"

#include "runtime/define_primitive_type.h"
#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
#include "vec/aggregate_functions/helpers.h"

namespace doris::vectorized {
#include "common/compile_check_begin.h"

void register_aggregate_function_bit(AggregateFunctionSimpleFactory& factory) {
using creator = creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT,
TYPE_LARGEINT>;
factory.register_function_both(
"group_bit_or", creator_with_integer_type::creator<AggregateFunctionBitwise,
AggregateFunctionGroupBitOrData>);
"group_bit_or",
creator::creator<AggregateFunctionBitwise, AggregateFunctionGroupBitOrData>);
factory.register_function_both(
"group_bit_and", creator_with_integer_type::creator<AggregateFunctionBitwise,
AggregateFunctionGroupBitAndData>);
"group_bit_and",
creator::creator<AggregateFunctionBitwise, AggregateFunctionGroupBitAndData>);
factory.register_function_both(
"group_bit_xor", creator_with_integer_type::creator<AggregateFunctionBitwise,
AggregateFunctionGroupBitXorData>);
"group_bit_xor",
creator::creator<AggregateFunctionBitwise, AggregateFunctionGroupBitXorData>);
}

} // namespace doris::vectorized
24 changes: 10 additions & 14 deletions be/src/vec/aggregate_functions/aggregate_function_histogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <fmt/format.h>
#include <glog/logging.h>

#include "runtime/define_primitive_type.h"
#include "vec/aggregate_functions/factory_helpers.h"
#include "vec/aggregate_functions/helpers.h"
#include "vec/data_types/data_type.h"

Expand All @@ -36,24 +38,18 @@ AggregateFunctionPtr create_aggregate_function_histogram(const std::string& name
const DataTypes& argument_types,
const bool result_is_nullable,
const AggregateFunctionAttr& attr) {
AggregateFunctionPtr result;
assert_arity_range(name, argument_types, 1, 2);
using creator = creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT,
TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMAL32,
TYPE_DECIMAL64, TYPE_DECIMAL128I, TYPE_DECIMAL256,
TYPE_VARCHAR, TYPE_DATEV2, TYPE_DATETIMEV2>;
if (argument_types.size() == 2) {
result = creator_with_any::create<HistogramWithInputParam, AggregateFunctionHistogramData>(
argument_types, result_is_nullable, attr);
} else if (argument_types.size() == 1) {
result = creator_with_any::create<HistogramNormal, AggregateFunctionHistogramData>(
return creator::create<HistogramWithInputParam, AggregateFunctionHistogramData>(
argument_types, result_is_nullable, attr);
} else {
throw Exception(ErrorCode::INVALID_ARGUMENT,
"Aggregate function histogram requires 1 or 2 arguments, but got {}",
argument_types.size());
}
if (!result) {
throw Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"Aggregate function histogram does not support type {}",
argument_types[0]->get_primitive_type());
return creator::create<HistogramNormal, AggregateFunctionHistogramData>(
argument_types, result_is_nullable, attr);
}
return result;
}

void register_aggregate_function_histogram(AggregateFunctionSimpleFactory& factory) {
Expand Down
66 changes: 13 additions & 53 deletions be/src/vec/aggregate_functions/aggregate_function_kurtosis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@
#include "vec/aggregate_functions/aggregate_function.h"
#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
#include "vec/aggregate_functions/aggregate_function_statistic.h"
#include "vec/aggregate_functions/factory_helpers.h"
#include "vec/aggregate_functions/helpers.h"
#include "vec/data_types/data_type.h"

namespace doris::vectorized {
#include "common/compile_check_begin.h"

template <PrimitiveType T>
AggregateFunctionPtr type_dispatch_for_aggregate_function_kurt(const DataTypes& argument_types,
const bool result_is_nullable,
bool nullable_input,
const AggregateFunctionAttr& attr) {
using StatFunctionTemplate = StatFuncOneArg<T, 4>;
AggregateFunctionPtr create_aggregate_function_kurt(const std::string& name,
const DataTypes& argument_types,
const bool result_is_nullable,
const AggregateFunctionAttr& attr) {
assert_arity_range(name, argument_types, 1, 1);
if (!result_is_nullable) {
throw doris::Exception(ErrorCode::INTERNAL_ERROR,
"Aggregate function {} requires result_is_nullable", name);
}

const bool nullable_input = argument_types[0]->is_nullable();
using StatFunctionTemplate = StatFuncOneArg<TYPE_DOUBLE, 4>;

if (nullable_input) {
return creator_without_type::create_ignore_nullable<
Expand All @@ -40,53 +47,6 @@ AggregateFunctionPtr type_dispatch_for_aggregate_function_kurt(const DataTypes&
AggregateFunctionVarianceSimple<StatFunctionTemplate, false>>(
argument_types, result_is_nullable, attr, STATISTICS_FUNCTION_KIND::KURT_POP);
}
};

AggregateFunctionPtr create_aggregate_function_kurt(const std::string& name,
const DataTypes& argument_types,
const bool result_is_nullable,
const AggregateFunctionAttr& attr) {
if (argument_types.size() != 1) {
LOG(WARNING) << "aggregate function " << name << " requires exactly 1 argument";
return nullptr;
}

if (!result_is_nullable) {
LOG(WARNING) << "aggregate function " << name << " requires nullable result type";
return nullptr;
}

const bool nullable_input = argument_types[0]->is_nullable();
switch (argument_types[0]->get_primitive_type()) {
case PrimitiveType::TYPE_BOOLEAN:
return type_dispatch_for_aggregate_function_kurt<TYPE_BOOLEAN>(
argument_types, result_is_nullable, nullable_input, attr);
case PrimitiveType::TYPE_TINYINT:
return type_dispatch_for_aggregate_function_kurt<TYPE_TINYINT>(
argument_types, result_is_nullable, nullable_input, attr);
case PrimitiveType::TYPE_SMALLINT:
return type_dispatch_for_aggregate_function_kurt<TYPE_SMALLINT>(
argument_types, result_is_nullable, nullable_input, attr);
case PrimitiveType::TYPE_INT:
return type_dispatch_for_aggregate_function_kurt<TYPE_INT>(
argument_types, result_is_nullable, nullable_input, attr);
case PrimitiveType::TYPE_BIGINT:
return type_dispatch_for_aggregate_function_kurt<TYPE_BIGINT>(
argument_types, result_is_nullable, nullable_input, attr);
case PrimitiveType::TYPE_LARGEINT:
return type_dispatch_for_aggregate_function_kurt<TYPE_LARGEINT>(
argument_types, result_is_nullable, nullable_input, attr);
case PrimitiveType::TYPE_FLOAT:
return type_dispatch_for_aggregate_function_kurt<TYPE_FLOAT>(
argument_types, result_is_nullable, nullable_input, attr);
case PrimitiveType::TYPE_DOUBLE:
return type_dispatch_for_aggregate_function_kurt<TYPE_DOUBLE>(
argument_types, result_is_nullable, nullable_input, attr);
default:
LOG(WARNING) << "unsupported input type " << argument_types[0]->get_name()
<< " for aggregate function " << name;
return nullptr;
}
}

void register_aggregate_function_kurtosis(AggregateFunctionSimpleFactory& factory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,72 +24,26 @@ namespace doris::vectorized {

const std::string AggregateFunctionLinearHistogramConsts::NAME = "linear_histogram";

template <PrimitiveType T>
AggregateFunctionPtr create_agg_function_linear_histogram(const DataTypes& argument_types,
const bool result_is_nullable,
const AggregateFunctionAttr& attr) {
bool has_offset = (argument_types.size() == 3);
template <PrimitiveType T, typename Data>
using HistogramWithInputParam = AggregateFunctionLinearHistogram<T, Data, true>;

if (has_offset) {
return creator_without_type::create<
AggregateFunctionLinearHistogram<T, AggregateFunctionLinearHistogramData<T>, true>>(
argument_types, result_is_nullable, attr);
} else {
return creator_without_type::create<AggregateFunctionLinearHistogram<
T, AggregateFunctionLinearHistogramData<T>, false>>(argument_types,
result_is_nullable, attr);
}
}
template <PrimitiveType T, typename Data>
using HistogramNormal = AggregateFunctionLinearHistogram<T, Data, false>;

AggregateFunctionPtr create_aggregate_function_linear_histogram(const std::string& name,
const DataTypes& argument_types,
const bool result_is_nullable,
const AggregateFunctionAttr& attr) {
switch (argument_types[0]->get_primitive_type()) {
case PrimitiveType::TYPE_BOOLEAN:
return create_agg_function_linear_histogram<TYPE_BOOLEAN>(argument_types,
result_is_nullable, attr);
case PrimitiveType::TYPE_TINYINT:
return create_agg_function_linear_histogram<TYPE_TINYINT>(argument_types,
result_is_nullable, attr);
case PrimitiveType::TYPE_SMALLINT:
return create_agg_function_linear_histogram<TYPE_SMALLINT>(argument_types,
result_is_nullable, attr);
case PrimitiveType::TYPE_INT:
return create_agg_function_linear_histogram<TYPE_INT>(argument_types, result_is_nullable,
attr);
case PrimitiveType::TYPE_BIGINT:
return create_agg_function_linear_histogram<TYPE_BIGINT>(argument_types, result_is_nullable,
attr);
case PrimitiveType::TYPE_LARGEINT:
return create_agg_function_linear_histogram<TYPE_LARGEINT>(argument_types,
result_is_nullable, attr);
case PrimitiveType::TYPE_FLOAT:
return create_agg_function_linear_histogram<TYPE_FLOAT>(argument_types, result_is_nullable,
attr);
case PrimitiveType::TYPE_DOUBLE:
return create_agg_function_linear_histogram<TYPE_DOUBLE>(argument_types, result_is_nullable,
attr);
case PrimitiveType::TYPE_DECIMAL32:
return create_agg_function_linear_histogram<TYPE_DECIMAL32>(argument_types,
result_is_nullable, attr);
case PrimitiveType::TYPE_DECIMAL64:
return create_agg_function_linear_histogram<TYPE_DECIMAL64>(argument_types,
result_is_nullable, attr);
case PrimitiveType::TYPE_DECIMAL128I:
return create_agg_function_linear_histogram<TYPE_DECIMAL128I>(argument_types,
result_is_nullable, attr);
case PrimitiveType::TYPE_DECIMALV2:
return create_agg_function_linear_histogram<TYPE_DECIMALV2>(argument_types,
result_is_nullable, attr);
case PrimitiveType::TYPE_DECIMAL256:
return create_agg_function_linear_histogram<TYPE_DECIMAL256>(argument_types,
result_is_nullable, attr);
default:

LOG(WARNING) << fmt::format("unsupported input type {} for aggregate function {}",
argument_types[0]->get_name(), name);
return nullptr;
using creator = creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT,
TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMAL32,
TYPE_DECIMAL64, TYPE_DECIMAL128I, TYPE_DECIMAL256>;
bool has_offset = (argument_types.size() == 3);
if (has_offset) {
return creator::create<HistogramWithInputParam, AggregateFunctionLinearHistogramData>(
argument_types, result_is_nullable, attr);
} else {
return creator::create<HistogramNormal, AggregateFunctionLinearHistogramData>(
argument_types, result_is_nullable, attr);
}
}

Expand Down
66 changes: 13 additions & 53 deletions be/src/vec/aggregate_functions/aggregate_function_skew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@
#include "vec/aggregate_functions/aggregate_function.h"
#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
#include "vec/aggregate_functions/aggregate_function_statistic.h"
#include "vec/aggregate_functions/factory_helpers.h"
#include "vec/aggregate_functions/helpers.h"
#include "vec/data_types/data_type.h"

namespace doris::vectorized {
#include "common/compile_check_begin.h"

template <PrimitiveType T>
AggregateFunctionPtr type_dispatch_for_aggregate_function_skew(const DataTypes& argument_types,
const bool result_is_nullable,
const AggregateFunctionAttr& attr,
bool nullable_input) {
using StatFunctionTemplate = StatFuncOneArg<T, 3>;
AggregateFunctionPtr create_aggregate_function_skew(const std::string& name,
const DataTypes& argument_types,
const bool result_is_nullable,
const AggregateFunctionAttr& attr) {
assert_arity_range(name, argument_types, 1, 1);
if (!result_is_nullable) {
throw doris::Exception(ErrorCode::INTERNAL_ERROR,
"Aggregate function {} requires result_is_nullable", name);
}

const bool nullable_input = argument_types[0]->is_nullable();
using StatFunctionTemplate = StatFuncOneArg<TYPE_DOUBLE, 3>;

if (nullable_input) {
return creator_without_type::create_ignore_nullable<
Expand All @@ -40,53 +47,6 @@ AggregateFunctionPtr type_dispatch_for_aggregate_function_skew(const DataTypes&
AggregateFunctionVarianceSimple<StatFunctionTemplate, false>>(
argument_types, result_is_nullable, attr, STATISTICS_FUNCTION_KIND::SKEW_POP);
}
};

AggregateFunctionPtr create_aggregate_function_skew(const std::string& name,
const DataTypes& argument_types,
const bool result_is_nullable,
const AggregateFunctionAttr& attr) {
if (argument_types.size() != 1) {
LOG(WARNING) << "aggregate function " << name << " requires exactly 1 argument";
return nullptr;
}

if (!result_is_nullable) {
LOG(WARNING) << "aggregate function " << name << " requires nullable result type";
return nullptr;
}

const bool nullable_input = argument_types[0]->is_nullable();
switch (argument_types[0]->get_primitive_type()) {
case PrimitiveType::TYPE_BOOLEAN:
return type_dispatch_for_aggregate_function_skew<TYPE_BOOLEAN>(
argument_types, result_is_nullable, attr, nullable_input);
case PrimitiveType::TYPE_TINYINT:
return type_dispatch_for_aggregate_function_skew<TYPE_TINYINT>(
argument_types, result_is_nullable, attr, nullable_input);
case PrimitiveType::TYPE_SMALLINT:
return type_dispatch_for_aggregate_function_skew<TYPE_SMALLINT>(
argument_types, result_is_nullable, attr, nullable_input);
case PrimitiveType::TYPE_INT:
return type_dispatch_for_aggregate_function_skew<TYPE_INT>(
argument_types, result_is_nullable, attr, nullable_input);
case PrimitiveType::TYPE_BIGINT:
return type_dispatch_for_aggregate_function_skew<TYPE_BIGINT>(
argument_types, result_is_nullable, attr, nullable_input);
case PrimitiveType::TYPE_LARGEINT:
return type_dispatch_for_aggregate_function_skew<TYPE_LARGEINT>(
argument_types, result_is_nullable, attr, nullable_input);
case PrimitiveType::TYPE_FLOAT:
return type_dispatch_for_aggregate_function_skew<TYPE_FLOAT>(
argument_types, result_is_nullable, attr, nullable_input);
case PrimitiveType::TYPE_DOUBLE:
return type_dispatch_for_aggregate_function_skew<TYPE_DOUBLE>(
argument_types, result_is_nullable, attr, nullable_input);
default:
LOG(WARNING) << "unsupported input type " << argument_types[0]->get_name()
<< " for aggregate function " << name;
return nullptr;
}
}

void register_aggregate_function_skewness(AggregateFunctionSimpleFactory& factory) {
Expand Down
7 changes: 0 additions & 7 deletions be/test/vec/aggregate_functions/agg_histogram_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ TEST_F(VAggHistogramTest, test_empty) {
test_agg_histogram<DataTypeFloat32>();
test_agg_histogram<DataTypeFloat64>();

test_agg_histogram<DataTypeDate>();
test_agg_histogram<DataTypeDateTime>();
test_agg_histogram<DataTypeString>();
test_agg_histogram<DataTypeDecimalV2>();
}

TEST_F(VAggHistogramTest, test_with_data) {
Expand All @@ -231,13 +228,9 @@ TEST_F(VAggHistogramTest, test_with_data) {
test_agg_histogram<DataTypeFloat32>(100, 5);
test_agg_histogram<DataTypeFloat64>(100, 5);

test_agg_histogram<DataTypeDate>(100, 5);
test_agg_histogram<DataTypeDateV2>(100, 5);

test_agg_histogram<DataTypeDateTime>(100, 5);
test_agg_histogram<DataTypeDateTimeV2>(100, 5);

test_agg_histogram<DataTypeDecimalV2>(100, 5);
}

} // namespace doris::vectorized
Loading
Loading