1#include <Storages/IStorage.h>
2#include <Parsers/ASTOptimizeQuery.h>
3#include <Interpreters/Context.h>
4#include <Interpreters/DDLWorker.h>
5#include <Interpreters/InterpreterOptimizeQuery.h>
6#include <Common/typeid_cast.h>
7
8
9namespace DB
10{
11
12namespace ErrorCodes
13{
14 extern const int BAD_ARGUMENTS;
15}
16
17
18BlockIO InterpreterOptimizeQuery::execute()
19{
20 const auto & ast = query_ptr->as<ASTOptimizeQuery &>();
21
22 if (!ast.cluster.empty())
23 return executeDDLQueryOnCluster(query_ptr, context, {ast.database});
24
25 StoragePtr table = context.getTable(ast.database, ast.table);
26 table->optimize(query_ptr, ast.partition, ast.final, ast.deduplicate, context);
27 return {};
28}
29
30}
31