2012-07-31 19:08:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/IAST.h>
|
2018-10-18 15:03:14 +00:00
|
|
|
#include <Parsers/ASTQueryWithTableAndOutput.h>
|
2018-07-20 05:46:48 +00:00
|
|
|
#include <Parsers/ASTQueryWithOnCluster.h>
|
2012-07-31 19:08:49 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** OPTIMIZE query
|
2012-07-31 19:08:49 +00:00
|
|
|
*/
|
2018-10-18 15:03:14 +00:00
|
|
|
class ASTOptimizeQuery : public ASTQueryWithTableAndOutput, public ASTQueryWithOnCluster
|
2012-07-31 19:08:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-05-27 17:27:16 +00:00
|
|
|
/// The partition to optimize can be specified.
|
2017-09-06 20:34:26 +00:00
|
|
|
ASTPtr partition;
|
2017-05-27 17:27:16 +00:00
|
|
|
/// A flag can be specified - perform optimization "to the end" instead of one step.
|
2017-04-01 07:20:54 +00:00
|
|
|
bool final;
|
2017-04-13 13:13:08 +00:00
|
|
|
/// Do deduplicate (default: false)
|
|
|
|
bool deduplicate;
|
2016-05-16 18:43:38 +00:00
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** Get the text that identifies this element. */
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char delim) const override
|
|
|
|
{
|
|
|
|
return "OptimizeQuery" + (delim + database) + delim + table + (final ? "_final" : "") + (deduplicate ? "_deduplicate" : "");
|
|
|
|
}
|
2012-07-31 19:08:49 +00:00
|
|
|
|
2017-09-06 20:34:26 +00:00
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
|
|
|
auto res = std::make_shared<ASTOptimizeQuery>(*this);
|
|
|
|
res->children.clear();
|
|
|
|
|
|
|
|
if (partition)
|
|
|
|
{
|
|
|
|
res->partition = partition->clone();
|
|
|
|
res->children.push_back(res->partition);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2015-08-05 21:38:31 +00:00
|
|
|
|
2018-07-20 05:46:48 +00:00
|
|
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2018-10-24 15:31:07 +00:00
|
|
|
ASTPtr getRewrittenASTWithoutOnCluster(const std::string &new_database) const override
|
|
|
|
{
|
|
|
|
return removeOnCluster<ASTOptimizeQuery>(clone(), new_database);
|
|
|
|
}
|
2012-07-31 19:08:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|