ClickHouse/dbms/src/Parsers/ASTOptimizeQuery.h

52 lines
1.3 KiB
C++
Raw Normal View History

2012-07-31 19:08:49 +00:00
#pragma once
#include <Parsers/IAST.h>
#include <Parsers/ASTQueryWithTableAndOutput.h>
#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
*/
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.
ASTPtr partition;
2017-05-27 17:27:16 +00:00
/// A flag can be specified - perform optimization "to the end" instead of one step.
bool final;
/// Do deduplicate (default: false)
bool deduplicate;
2017-05-27 17:27:16 +00:00
/** Get the text that identifies this element. */
String getID(char delim) const override
{
return "OptimizeQuery" + (delim + database) + delim + table + (final ? "_final" : "") + (deduplicate ? "_deduplicate" : "");
}
2012-07-31 19:08:49 +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;
}
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
ASTPtr getRewrittenASTWithoutOnCluster(const std::string &new_database) const override
{
return removeOnCluster<ASTOptimizeQuery>(clone(), new_database);
}
2012-07-31 19:08:49 +00:00
};
}