ClickHouse

Форк
0
/
AggregateFunctionForEach.cpp 
55 строк · 1.5 Кб
1
#include "AggregateFunctionForEach.h"
2
#include "AggregateFunctionCombinatorFactory.h"
3

4
#include <Common/typeid_cast.h>
5

6

7
namespace DB
8
{
9

10
namespace ErrorCodes
11
{
12
    extern const int ILLEGAL_TYPE_OF_ARGUMENT;
13
}
14

15
namespace
16
{
17

18
class AggregateFunctionCombinatorForEach final : public IAggregateFunctionCombinator
19
{
20
public:
21
    String getName() const override { return "ForEach"; }
22

23
    DataTypes transformArguments(const DataTypes & arguments) const override
24
    {
25
        DataTypes nested_arguments;
26
        for (const auto & type : arguments)
27
        {
28
            if (const DataTypeArray * array = typeid_cast<const DataTypeArray *>(type.get()))
29
                nested_arguments.push_back(array->getNestedType());
30
            else
31
                throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument for "
32
                                "aggregate function with {} suffix. Must be array.", type->getName(), getName());
33
        }
34

35
        return nested_arguments;
36
    }
37

38
    AggregateFunctionPtr transformAggregateFunction(
39
        const AggregateFunctionPtr & nested_function,
40
        const AggregateFunctionProperties &,
41
        const DataTypes & arguments,
42
        const Array & params) const override
43
    {
44
        return std::make_shared<AggregateFunctionForEach>(nested_function, arguments, params);
45
    }
46
};
47

48
}
49

50
void registerAggregateFunctionCombinatorForEach(AggregateFunctionCombinatorFactory & factory)
51
{
52
    factory.registerCombinator(std::make_shared<AggregateFunctionCombinatorForEach>());
53
}
54

55
}
56

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.