mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 10:52:30 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include <Storages/IStorage.h>
|
|
#include <Parsers/ASTOptimizeQuery.h>
|
|
#include <Interpreters/Context.h>
|
|
#include <Interpreters/DDLWorker.h>
|
|
#include <Interpreters/InterpreterOptimizeQuery.h>
|
|
#include <Access/AccessRightsElement.h>
|
|
#include <Common/typeid_cast.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
}
|
|
|
|
|
|
BlockIO InterpreterOptimizeQuery::execute()
|
|
{
|
|
const auto & ast = query_ptr->as<ASTOptimizeQuery &>();
|
|
|
|
if (!ast.cluster.empty())
|
|
return executeDDLQueryOnCluster(query_ptr, context, getRequiredAccess());
|
|
|
|
context.checkAccess(getRequiredAccess());
|
|
|
|
auto table_id = context.resolveStorageID(ast, Context::ResolveOrdinary);
|
|
StoragePtr table = DatabaseCatalog::instance().getTable(table_id);
|
|
table->optimize(query_ptr, ast.partition, ast.final, ast.deduplicate, context);
|
|
return {};
|
|
}
|
|
|
|
|
|
AccessRightsElements InterpreterOptimizeQuery::getRequiredAccess() const
|
|
{
|
|
const auto & optimize = query_ptr->as<const ASTOptimizeQuery &>();
|
|
AccessRightsElements required_access;
|
|
required_access.emplace_back(AccessType::OPTIMIZE, optimize.database, optimize.table);
|
|
return required_access;
|
|
}
|
|
|
|
}
|