ClickHouse/dbms/src/TableFunctions/TableFunctionFactory.cpp
2016-05-13 06:22:16 +03:00

33 lines
909 B
C++

#include <DB/TableFunctions/TableFunctionMerge.h>
#include <DB/TableFunctions/TableFunctionRemote.h>
#include <DB/TableFunctions/TableFunctionShardByHash.h>
#include <DB/TableFunctions/TableFunctionFactory.h>
namespace DB
{
namespace ErrorCodes
{
extern const int READONLY;
extern const int UNKNOWN_FUNCTION;
}
TableFunctionPtr TableFunctionFactory::get(
const String & name,
const Context & context) const
{
if (context.getSettings().limits.readonly == 1) /** Например, для readonly = 2 - разрешено. */
throw Exception("Table functions are forbidden in readonly mode", ErrorCodes::READONLY);
if (name == "merge") return new TableFunctionMerge;
else if (name == "remote") return new TableFunctionRemote;
else if (name == "shardByHash") return new TableFunctionShardByHash;
else
throw Exception("Unknown table function " + name, ErrorCodes::UNKNOWN_FUNCTION);
}
}