mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
Added field "is_deterministic" to system.functions
This commit is contained in:
parent
711876dfa8
commit
4373ed0f98
@ -1,5 +1,6 @@
|
|||||||
#include <AggregateFunctions/AggregateFunctionFactory.h>
|
#include <AggregateFunctions/AggregateFunctionFactory.h>
|
||||||
#include <DataTypes/DataTypeMap.h>
|
#include <DataTypes/DataTypeMap.h>
|
||||||
|
#include <DataTypes/DataTypeNullable.h>
|
||||||
#include <DataTypes/DataTypeString.h>
|
#include <DataTypes/DataTypeString.h>
|
||||||
#include <DataTypes/DataTypesNumber.h>
|
#include <DataTypes/DataTypesNumber.h>
|
||||||
#include <DataTypes/DataTypeEnum.h>
|
#include <DataTypes/DataTypeEnum.h>
|
||||||
@ -29,6 +30,7 @@ namespace
|
|||||||
MutableColumns & res_columns,
|
MutableColumns & res_columns,
|
||||||
const String & name,
|
const String & name,
|
||||||
UInt64 is_aggregate,
|
UInt64 is_aggregate,
|
||||||
|
std::optional<UInt64> is_deterministic,
|
||||||
const String & create_query,
|
const String & create_query,
|
||||||
FunctionOrigin function_origin,
|
FunctionOrigin function_origin,
|
||||||
const Factory & factory)
|
const Factory & factory)
|
||||||
@ -36,53 +38,58 @@ namespace
|
|||||||
res_columns[0]->insert(name);
|
res_columns[0]->insert(name);
|
||||||
res_columns[1]->insert(is_aggregate);
|
res_columns[1]->insert(is_aggregate);
|
||||||
|
|
||||||
|
if (!is_deterministic.has_value())
|
||||||
|
res_columns[2]->insertDefault();
|
||||||
|
else
|
||||||
|
res_columns[2]->insert(*is_deterministic);
|
||||||
|
|
||||||
if constexpr (std::is_same_v<Factory, UserDefinedSQLFunctionFactory> || std::is_same_v<Factory, UserDefinedExecutableFunctionFactory>)
|
if constexpr (std::is_same_v<Factory, UserDefinedSQLFunctionFactory> || std::is_same_v<Factory, UserDefinedExecutableFunctionFactory>)
|
||||||
{
|
{
|
||||||
res_columns[2]->insert(false);
|
res_columns[3]->insert(false);
|
||||||
res_columns[3]->insertDefault();
|
res_columns[4]->insertDefault();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res_columns[2]->insert(factory.isCaseInsensitive(name));
|
res_columns[3]->insert(factory.isCaseInsensitive(name));
|
||||||
if (factory.isAlias(name))
|
if (factory.isAlias(name))
|
||||||
res_columns[3]->insert(factory.aliasTo(name));
|
res_columns[4]->insert(factory.aliasTo(name));
|
||||||
else
|
else
|
||||||
res_columns[3]->insertDefault();
|
res_columns[4]->insertDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
res_columns[4]->insert(create_query);
|
res_columns[5]->insert(create_query);
|
||||||
res_columns[5]->insert(static_cast<Int8>(function_origin));
|
res_columns[6]->insert(static_cast<Int8>(function_origin));
|
||||||
|
|
||||||
if constexpr (std::is_same_v<Factory, FunctionFactory>)
|
if constexpr (std::is_same_v<Factory, FunctionFactory>)
|
||||||
{
|
{
|
||||||
if (factory.isAlias(name))
|
if (factory.isAlias(name))
|
||||||
{
|
{
|
||||||
res_columns[6]->insertDefault();
|
|
||||||
res_columns[7]->insertDefault();
|
res_columns[7]->insertDefault();
|
||||||
res_columns[8]->insertDefault();
|
res_columns[8]->insertDefault();
|
||||||
res_columns[9]->insertDefault();
|
res_columns[9]->insertDefault();
|
||||||
res_columns[10]->insertDefault();
|
res_columns[10]->insertDefault();
|
||||||
res_columns[11]->insertDefault();
|
res_columns[11]->insertDefault();
|
||||||
|
res_columns[12]->insertDefault();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto documentation = factory.getDocumentation(name);
|
auto documentation = factory.getDocumentation(name);
|
||||||
res_columns[6]->insert(documentation.description);
|
res_columns[7]->insert(documentation.description);
|
||||||
res_columns[7]->insert(documentation.syntax);
|
res_columns[8]->insert(documentation.syntax);
|
||||||
res_columns[8]->insert(documentation.argumentsAsString());
|
res_columns[9]->insert(documentation.argumentsAsString());
|
||||||
res_columns[9]->insert(documentation.returned_value);
|
res_columns[10]->insert(documentation.returned_value);
|
||||||
res_columns[10]->insert(documentation.examplesAsString());
|
res_columns[11]->insert(documentation.examplesAsString());
|
||||||
res_columns[11]->insert(documentation.categoriesAsString());
|
res_columns[12]->insert(documentation.categoriesAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res_columns[6]->insertDefault();
|
|
||||||
res_columns[7]->insertDefault();
|
res_columns[7]->insertDefault();
|
||||||
res_columns[8]->insertDefault();
|
res_columns[8]->insertDefault();
|
||||||
res_columns[9]->insertDefault();
|
res_columns[9]->insertDefault();
|
||||||
res_columns[10]->insertDefault();
|
res_columns[10]->insertDefault();
|
||||||
res_columns[11]->insertDefault();
|
res_columns[11]->insertDefault();
|
||||||
|
res_columns[12]->insertDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,6 +109,7 @@ NamesAndTypesList StorageSystemFunctions::getNamesAndTypes()
|
|||||||
return {
|
return {
|
||||||
{"name", std::make_shared<DataTypeString>()},
|
{"name", std::make_shared<DataTypeString>()},
|
||||||
{"is_aggregate", std::make_shared<DataTypeUInt8>()},
|
{"is_aggregate", std::make_shared<DataTypeUInt8>()},
|
||||||
|
{"is_deterministic", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>())},
|
||||||
{"case_insensitive", std::make_shared<DataTypeUInt8>()},
|
{"case_insensitive", std::make_shared<DataTypeUInt8>()},
|
||||||
{"alias_to", std::make_shared<DataTypeString>()},
|
{"alias_to", std::make_shared<DataTypeString>()},
|
||||||
{"create_query", std::make_shared<DataTypeString>()},
|
{"create_query", std::make_shared<DataTypeString>()},
|
||||||
@ -121,14 +129,25 @@ void StorageSystemFunctions::fillData(MutableColumns & res_columns, ContextPtr c
|
|||||||
const auto & function_names = functions_factory.getAllRegisteredNames();
|
const auto & function_names = functions_factory.getAllRegisteredNames();
|
||||||
for (const auto & function_name : function_names)
|
for (const auto & function_name : function_names)
|
||||||
{
|
{
|
||||||
fillRow(res_columns, function_name, UInt64(0), "", FunctionOrigin::SYSTEM, functions_factory);
|
std::optional<UInt64> is_deterministic;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
is_deterministic = functions_factory.tryGet(function_name, context)->isDeterministic();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
/// Some functions throw because they need special configuration or setup before use.
|
||||||
|
/// Ignore the exception and simply show is_deterministic = NULL.
|
||||||
|
}
|
||||||
|
|
||||||
|
fillRow(res_columns, function_name, 0, is_deterministic, "", FunctionOrigin::SYSTEM, functions_factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto & aggregate_functions_factory = AggregateFunctionFactory::instance();
|
const auto & aggregate_functions_factory = AggregateFunctionFactory::instance();
|
||||||
const auto & aggregate_function_names = aggregate_functions_factory.getAllRegisteredNames();
|
const auto & aggregate_function_names = aggregate_functions_factory.getAllRegisteredNames();
|
||||||
for (const auto & function_name : aggregate_function_names)
|
for (const auto & function_name : aggregate_function_names)
|
||||||
{
|
{
|
||||||
fillRow(res_columns, function_name, UInt64(1), "", FunctionOrigin::SYSTEM, aggregate_functions_factory);
|
fillRow(res_columns, function_name, 1, {1}, "", FunctionOrigin::SYSTEM, aggregate_functions_factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto & user_defined_sql_functions_factory = UserDefinedSQLFunctionFactory::instance();
|
const auto & user_defined_sql_functions_factory = UserDefinedSQLFunctionFactory::instance();
|
||||||
@ -136,14 +155,14 @@ void StorageSystemFunctions::fillData(MutableColumns & res_columns, ContextPtr c
|
|||||||
for (const auto & function_name : user_defined_sql_functions_names)
|
for (const auto & function_name : user_defined_sql_functions_names)
|
||||||
{
|
{
|
||||||
auto create_query = queryToString(user_defined_sql_functions_factory.get(function_name));
|
auto create_query = queryToString(user_defined_sql_functions_factory.get(function_name));
|
||||||
fillRow(res_columns, function_name, UInt64(0), create_query, FunctionOrigin::SQL_USER_DEFINED, user_defined_sql_functions_factory);
|
fillRow(res_columns, function_name, 0, {0}, create_query, FunctionOrigin::SQL_USER_DEFINED, user_defined_sql_functions_factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto & user_defined_executable_functions_factory = UserDefinedExecutableFunctionFactory::instance();
|
const auto & user_defined_executable_functions_factory = UserDefinedExecutableFunctionFactory::instance();
|
||||||
const auto & user_defined_executable_functions_names = user_defined_executable_functions_factory.getRegisteredNames(context);
|
const auto & user_defined_executable_functions_names = user_defined_executable_functions_factory.getRegisteredNames(context);
|
||||||
for (const auto & function_name : user_defined_executable_functions_names)
|
for (const auto & function_name : user_defined_executable_functions_names)
|
||||||
{
|
{
|
||||||
fillRow(res_columns, function_name, UInt64(0), "", FunctionOrigin::EXECUTABLE_USER_DEFINED, user_defined_executable_functions_factory);
|
fillRow(res_columns, function_name, 0, {0}, "", FunctionOrigin::EXECUTABLE_USER_DEFINED, user_defined_executable_functions_factory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,6 +283,7 @@ CREATE TABLE system.functions
|
|||||||
(
|
(
|
||||||
`name` String,
|
`name` String,
|
||||||
`is_aggregate` UInt8,
|
`is_aggregate` UInt8,
|
||||||
|
`is_deterministic` Nullable(UInt8),
|
||||||
`case_insensitive` UInt8,
|
`case_insensitive` UInt8,
|
||||||
`alias_to` String,
|
`alias_to` String,
|
||||||
`create_query` String,
|
`create_query` String,
|
||||||
|
Loading…
Reference in New Issue
Block a user