2012-07-31 19:08:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Parsers/IAST.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/** OPTIMIZE запрос
|
|
|
|
*/
|
|
|
|
class ASTOptimizeQuery : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String database;
|
|
|
|
String table;
|
|
|
|
|
2016-05-16 18:43:38 +00:00
|
|
|
/// Может быть указана партиция, в которой производить оптимизацию.
|
|
|
|
String partition;
|
|
|
|
/// Может быть указан флаг - производить оптимизацию "до конца" вместо одного шага.
|
|
|
|
bool final;
|
|
|
|
|
2014-12-17 15:26:24 +00:00
|
|
|
ASTOptimizeQuery() = default;
|
|
|
|
ASTOptimizeQuery(const StringRange range_) : IAST(range_) {}
|
2016-05-16 18:43:38 +00:00
|
|
|
|
2012-07-31 19:08:49 +00:00
|
|
|
/** Получить текст, который идентифицирует этот элемент. */
|
2016-11-20 12:43:20 +00:00
|
|
|
String getID() const override { return "OptimizeQuery_" + database + "_" + table + "_" + partition + "_" + (final ? "final" : ""); };
|
2012-07-31 19:08:49 +00:00
|
|
|
|
2016-05-28 15:42:22 +00:00
|
|
|
ASTPtr clone() const override { return std::make_shared<ASTOptimizeQuery>(*this); }
|
2015-08-05 21:38:31 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "OPTIMIZE TABLE " << (settings.hilite ? hilite_none : "")
|
|
|
|
<< (!database.empty() ? backQuoteIfNeed(database) + "." : "") << backQuoteIfNeed(table);
|
2016-05-16 18:43:38 +00:00
|
|
|
|
|
|
|
if (!partition.empty())
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " PARTITION " << (settings.hilite ? hilite_none : "")
|
|
|
|
<< partition;
|
|
|
|
|
|
|
|
if (final)
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FINAL" << (settings.hilite ? hilite_none : "");
|
2015-08-05 21:38:31 +00:00
|
|
|
}
|
2012-07-31 19:08:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|