2017-01-21 04:24:28 +00:00
|
|
|
#include <DB/Common/Exception.h>
|
|
|
|
#include <DB/Interpreters/Context.h>
|
|
|
|
|
2014-01-28 16:45:10 +00:00
|
|
|
#include <DB/TableFunctions/TableFunctionMerge.h>
|
|
|
|
#include <DB/TableFunctions/TableFunctionRemote.h>
|
2016-05-13 03:22:16 +00:00
|
|
|
#include <DB/TableFunctions/TableFunctionShardByHash.h>
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
#include <DB/TableFunctions/TableFunctionFactory.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-11 21:46:36 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int READONLY;
|
|
|
|
extern const int UNKNOWN_FUNCTION;
|
|
|
|
}
|
|
|
|
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
TableFunctionPtr TableFunctionFactory::get(
|
2017-01-21 04:24:28 +00:00
|
|
|
const std::string & name,
|
2014-01-28 16:45:10 +00:00
|
|
|
const Context & context) const
|
|
|
|
{
|
2015-02-27 20:35:26 +00:00
|
|
|
if (context.getSettings().limits.readonly == 1) /** Например, для readonly = 2 - разрешено. */
|
2014-02-25 17:37:50 +00:00
|
|
|
throw Exception("Table functions are forbidden in readonly mode", ErrorCodes::READONLY);
|
|
|
|
|
2016-05-28 10:15: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>();
|
2014-01-28 16:45:10 +00:00
|
|
|
else
|
2014-02-26 10:52:22 +00:00
|
|
|
throw Exception("Unknown table function " + name, ErrorCodes::UNKNOWN_FUNCTION);
|
2014-01-28 16:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|