mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 13:32:13 +00:00
ee37f551a2
* make interpreter factory an instance * add registerInterpreter * register interpreters individually * try wire everything up * fix style * fix test
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
#include <Interpreters/InterpreterFactory.h>
|
|
#include <Interpreters/InterpreterDropNamedCollectionQuery.h>
|
|
#include <Parsers/ASTDropNamedCollectionQuery.h>
|
|
#include <Access/ContextAccess.h>
|
|
#include <Interpreters/Context.h>
|
|
#include <Interpreters/executeDDLQueryOnCluster.h>
|
|
#include <Common/NamedCollections/NamedCollectionUtils.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
BlockIO InterpreterDropNamedCollectionQuery::execute()
|
|
{
|
|
auto current_context = getContext();
|
|
const auto & query = query_ptr->as<const ASTDropNamedCollectionQuery &>();
|
|
|
|
current_context->checkAccess(AccessType::DROP_NAMED_COLLECTION, query.collection_name);
|
|
|
|
if (!query.cluster.empty())
|
|
{
|
|
DDLQueryOnClusterParams params;
|
|
return executeDDLQueryOnCluster(query_ptr, current_context, params);
|
|
}
|
|
|
|
NamedCollectionUtils::removeFromSQL(query, current_context);
|
|
return {};
|
|
}
|
|
|
|
void registerInterpreterDropNamedCollectionQuery(InterpreterFactory & factory)
|
|
{
|
|
auto create_fn = [] (const InterpreterFactory::Arguments & args)
|
|
{
|
|
return std::make_unique<InterpreterDropNamedCollectionQuery>(args.query, args.context);
|
|
};
|
|
factory.registerInterpreter("InterpreterDropNamedCollectionQuery", create_fn);
|
|
}
|
|
|
|
}
|