2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/Exception.h>
|
|
|
|
#include <Interpreters/Context.h>
|
2017-01-21 04:24:28 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <TableFunctions/TableFunctionMerge.h>
|
|
|
|
#include <TableFunctions/TableFunctionRemote.h>
|
|
|
|
#include <TableFunctions/TableFunctionShardByHash.h>
|
2014-01-28 16:45:10 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <TableFunctions/TableFunctionFactory.h>
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-11 21:46:36 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
extern const int READONLY;
|
|
|
|
extern const int UNKNOWN_FUNCTION;
|
2016-01-11 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
TableFunctionPtr TableFunctionFactory::get(
|
2017-04-01 07:20:54 +00:00
|
|
|
const std::string & name,
|
|
|
|
const Context & context) const
|
2014-01-28 16:45:10 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
if (context.getSettings().limits.readonly == 1) /** For example, for readonly = 2 - allowed. */
|
|
|
|
throw Exception("Table functions are forbidden in readonly mode", ErrorCodes::READONLY);
|
|
|
|
|
2017-05-23 18:44:36 +00:00
|
|
|
if (name == "merge") return std::make_shared<TableFunctionMerge>();
|
|
|
|
else if (name == "remote") return std::make_shared<TableFunctionRemote>();
|
|
|
|
else if (name == "shardByHash") return std::make_shared<TableFunctionShardByHash>();
|
2017-04-01 07:20:54 +00:00
|
|
|
else
|
|
|
|
throw Exception("Unknown table function " + name, ErrorCodes::UNKNOWN_FUNCTION);
|
2014-01-28 16:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|