2018-07-20 10:00:56 +00:00
|
|
|
#include <Storages/System/StorageSystemTableFunctions.h>
|
|
|
|
#include <TableFunctions/TableFunctionFactory.h>
|
2022-10-26 16:45:23 +00:00
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
|
2018-07-20 10:00:56 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2018-07-24 14:28:56 +00:00
|
|
|
|
2022-10-26 16:45:23 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int UNKNOWN_FUNCTION;
|
|
|
|
}
|
|
|
|
|
2024-01-12 15:39:22 +00:00
|
|
|
ColumnsDescription StorageSystemTableFunctions::getColumnsDescription()
|
2018-07-24 14:28:56 +00:00
|
|
|
{
|
2024-01-12 15:39:22 +00:00
|
|
|
return ColumnsDescription
|
|
|
|
{
|
|
|
|
{"name", std::make_shared<DataTypeString>(), "Name of a table function."},
|
|
|
|
{"description", std::make_shared<DataTypeString>(), "Brief description of a table function."},
|
|
|
|
{"allow_readonly", std::make_shared<DataTypeUInt8>(), "Flag that indicated whether a readonly user may use this function."}
|
|
|
|
};
|
2018-07-24 14:28:56 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
void StorageSystemTableFunctions::fillData(MutableColumns & res_columns, ContextPtr, const SelectQueryInfo &) const
|
2018-07-20 10:00:56 +00:00
|
|
|
{
|
2022-08-26 01:41:52 +00:00
|
|
|
const auto & factory = TableFunctionFactory::instance();
|
|
|
|
const auto & functions_names = factory.getAllRegisteredNames();
|
2019-08-03 11:02:40 +00:00
|
|
|
for (const auto & function_name : functions_names)
|
2018-07-20 10:00:56 +00:00
|
|
|
{
|
2019-08-03 11:02:40 +00:00
|
|
|
res_columns[0]->insert(function_name);
|
2022-10-26 16:45:23 +00:00
|
|
|
|
|
|
|
auto properties = factory.tryGetProperties(function_name);
|
|
|
|
if (properties)
|
|
|
|
{
|
|
|
|
res_columns[1]->insert(properties->documentation.description);
|
|
|
|
res_columns[2]->insert(properties->allow_readonly);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw Exception(ErrorCodes::UNKNOWN_FUNCTION, "Unknown table function {}", function_name);
|
2018-07-20 10:00:56 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-24 14:28:56 +00:00
|
|
|
|
2018-07-20 10:00:56 +00:00
|
|
|
}
|