1#include <AggregateFunctions/AggregateFunctionFactory.h>
2#include <DataTypes/DataTypeString.h>
3#include <DataTypes/DataTypesNumber.h>
4#include <Functions/FunctionFactory.h>
5#include <Functions/IFunction.h>
6#include <Interpreters/Context.h>
7#include <Storages/System/StorageSystemFunctions.h>
8
9
10namespace DB
11{
12namespace
13{
14 template <typename Factory>
15 void fillRow(MutableColumns & res_columns, const String & name, UInt64 is_aggregate, const Factory & f)
16 {
17 res_columns[0]->insert(name);
18 res_columns[1]->insert(is_aggregate);
19 res_columns[2]->insert(f.isCaseInsensitive(name));
20 if (f.isAlias(name))
21 res_columns[3]->insert(f.aliasTo(name));
22 else
23 res_columns[3]->insertDefault();
24 }
25}
26
27NamesAndTypesList StorageSystemFunctions::getNamesAndTypes()
28{
29 return {
30 {"name", std::make_shared<DataTypeString>()},
31 {"is_aggregate", std::make_shared<DataTypeUInt8>()},
32 {"case_insensitive", std::make_shared<DataTypeUInt8>()},
33 {"alias_to", std::make_shared<DataTypeString>()},
34 };
35}
36
37void StorageSystemFunctions::fillData(MutableColumns & res_columns, const Context &, const SelectQueryInfo &) const
38{
39 const auto & functions_factory = FunctionFactory::instance();
40 const auto & function_names = functions_factory.getAllRegisteredNames();
41 for (const auto & function_name : function_names)
42 {
43 fillRow(res_columns, function_name, UInt64(0), functions_factory);
44 }
45
46 const auto & aggregate_functions_factory = AggregateFunctionFactory::instance();
47 const auto & aggregate_function_names = aggregate_functions_factory.getAllRegisteredNames();
48 for (const auto & function_name : aggregate_function_names)
49 {
50 fillRow(res_columns, function_name, UInt64(1), aggregate_functions_factory);
51 }
52}
53}
54