ClickHouse/src/Storages/System/StorageSystemFunctions.cpp

54 lines
1.8 KiB
C++
Raw Normal View History

#include <AggregateFunctions/AggregateFunctionFactory.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Interpreters/Context.h>
#include <Storages/System/StorageSystemFunctions.h>
2016-12-08 02:49:04 +00:00
2015-04-24 15:49:30 +00:00
namespace DB
{
namespace
{
template <typename Factory>
void fillRow(MutableColumns & res_columns, const String & name, UInt64 is_aggregate, const Factory & f)
{
res_columns[0]->insert(name);
res_columns[1]->insert(is_aggregate);
res_columns[2]->insert(f.isCaseInsensitive(name));
if (f.isAlias(name))
res_columns[3]->insert(f.aliasTo(name));
else
2018-11-01 17:21:15 +00:00
res_columns[3]->insertDefault();
}
}
2015-04-24 15:49:30 +00:00
NamesAndTypesList StorageSystemFunctions::getNamesAndTypes()
{
return {
{"name", std::make_shared<DataTypeString>()},
{"is_aggregate", std::make_shared<DataTypeUInt8>()},
2018-07-25 16:19:11 +00:00
{"case_insensitive", std::make_shared<DataTypeUInt8>()},
{"alias_to", std::make_shared<DataTypeString>()},
};
2015-04-24 15:49:30 +00:00
}
void StorageSystemFunctions::fillData(MutableColumns & res_columns, const Context &, const SelectQueryInfo &) const
2015-04-24 15:49:30 +00:00
{
const auto & functions_factory = FunctionFactory::instance();
const auto & function_names = functions_factory.getAllRegisteredNames();
2019-08-03 11:02:40 +00:00
for (const auto & function_name : function_names)
{
2019-08-03 11:02:40 +00:00
fillRow(res_columns, function_name, UInt64(0), functions_factory);
}
const auto & aggregate_functions_factory = AggregateFunctionFactory::instance();
const auto & aggregate_function_names = aggregate_functions_factory.getAllRegisteredNames();
2019-08-03 11:02:40 +00:00
for (const auto & function_name : aggregate_function_names)
{
2019-08-03 11:02:40 +00:00
fillRow(res_columns, function_name, UInt64(1), aggregate_functions_factory);
}
2015-04-24 15:49:30 +00:00
}
2015-09-24 03:50:09 +00:00
}