#include #include #include #include #include #include #include namespace DB { namespace ErrorCodes { } BlockIO InterpreterOptimizeQuery::execute() { const auto & ast = query_ptr->as(); if (!ast.cluster.empty()) return executeDDLQueryOnCluster(query_ptr, context, getRequiredAccess()); context.checkAccess(getRequiredAccess()); StoragePtr table = DatabaseCatalog::instance().getTable(StorageID{ast, context}); table->optimize(query_ptr, ast.partition, ast.final, ast.deduplicate, context); return {}; } AccessRightsElements InterpreterOptimizeQuery::getRequiredAccess() const { const auto & optimize = query_ptr->as(); AccessRightsElements required_access; required_access.emplace_back(AccessType::OPTIMIZE, optimize.database, optimize.table); return required_access; } }