diff options
| author | vitalyisaev <[email protected]> | 2023-11-14 09:58:56 +0300 |
|---|---|---|
| committer | vitalyisaev <[email protected]> | 2023-11-14 10:20:20 +0300 |
| commit | c2b2dfd9827a400a8495e172a56343462e3ceb82 (patch) | |
| tree | cd4e4f597d01bede4c82dffeb2d780d0a9046bd0 /contrib/clickhouse/src/AggregateFunctions/AggregateFunctionForEach.cpp | |
| parent | d4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff) | |
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/AggregateFunctions/AggregateFunctionForEach.cpp')
| -rw-r--r-- | contrib/clickhouse/src/AggregateFunctions/AggregateFunctionForEach.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/AggregateFunctions/AggregateFunctionForEach.cpp b/contrib/clickhouse/src/AggregateFunctions/AggregateFunctionForEach.cpp new file mode 100644 index 00000000000..2e973b69fde --- /dev/null +++ b/contrib/clickhouse/src/AggregateFunctions/AggregateFunctionForEach.cpp @@ -0,0 +1,54 @@ +#include <AggregateFunctions/AggregateFunctionForEach.h> +#include <AggregateFunctions/AggregateFunctionCombinatorFactory.h> +#include <Common/typeid_cast.h> + + +namespace DB +{ + +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + +namespace +{ + +class AggregateFunctionCombinatorForEach final : public IAggregateFunctionCombinator +{ +public: + String getName() const override { return "ForEach"; } + + DataTypes transformArguments(const DataTypes & arguments) const override + { + DataTypes nested_arguments; + for (const auto & type : arguments) + { + if (const DataTypeArray * array = typeid_cast<const DataTypeArray *>(type.get())) + nested_arguments.push_back(array->getNestedType()); + else + throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument for " + "aggregate function with {} suffix. Must be array.", type->getName(), getName()); + } + + return nested_arguments; + } + + AggregateFunctionPtr transformAggregateFunction( + const AggregateFunctionPtr & nested_function, + const AggregateFunctionProperties &, + const DataTypes & arguments, + const Array & params) const override + { + return std::make_shared<AggregateFunctionForEach>(nested_function, arguments, params); + } +}; + +} + +void registerAggregateFunctionCombinatorForEach(AggregateFunctionCombinatorFactory & factory) +{ + factory.registerCombinator(std::make_shared<AggregateFunctionCombinatorForEach>()); +} + +} |
