ClickHouse/src/Storages/System/StorageSystemTableFunctions.cpp
Smita Kulkarni 6a8fa2d4a5 Added new field allow_readonly in system.table_functions to allow using table functions in readonly mode.
Implementation:
* Added a new field allow_readonly to table system.table_functions.
* Updated to use new field allow_readonly to allow using table functions in readonly mode.
* Added TableFunctionProperties similar to AggregateFunctionProperties.
* The functions allowed in readonly mode are in this set table_functions_allowed_in_readonly_mode.
Testing:
* Added a test for filesystem tests/queries/0_stateless/02473_functions_in_readonly_mode.sh
Documentation:
* Updated the english documentation for Table Functions.
2022-10-26 18:45:23 +02:00

43 lines
1.2 KiB
C++

#include <Storages/System/StorageSystemTableFunctions.h>
#include <TableFunctions/TableFunctionFactory.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB
{
namespace ErrorCodes
{
extern const int UNKNOWN_FUNCTION;
}
NamesAndTypesList StorageSystemTableFunctions::getNamesAndTypes()
{
return
{
{"name", std::make_shared<DataTypeString>()},
{"description", std::make_shared<DataTypeString>()},
{"allow_readonly", std::make_shared<DataTypeUInt8>()}
};
}
void StorageSystemTableFunctions::fillData(MutableColumns & res_columns, ContextPtr, const SelectQueryInfo &) const
{
const auto & factory = TableFunctionFactory::instance();
const auto & functions_names = factory.getAllRegisteredNames();
for (const auto & function_name : functions_names)
{
res_columns[0]->insert(function_name);
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);
}
}
}