mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-01 06:00:49 +00:00
41 lines
689 B
C++
41 lines
689 B
C++
#include <Functions/FunctionFactory.h>
|
|
#include <Common/Exception.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int UNKNOWN_FUNCTION;
|
|
}
|
|
|
|
FunctionFactory::FunctionFactory()
|
|
{
|
|
}
|
|
|
|
|
|
FunctionPtr FunctionFactory::get(
|
|
const std::string & name,
|
|
const Context & context) const
|
|
{
|
|
auto res = tryGet(name, context);
|
|
if (!res)
|
|
throw Exception("Unknown function " + name, ErrorCodes::UNKNOWN_FUNCTION);
|
|
return res;
|
|
}
|
|
|
|
|
|
FunctionPtr FunctionFactory::tryGet(
|
|
const std::string & name,
|
|
const Context & context) const
|
|
{
|
|
auto it = functions.find(name);
|
|
if (functions.end() != it)
|
|
return it->second(context);
|
|
else
|
|
return {};
|
|
}
|
|
|
|
}
|