2018-07-20 05:46:48 +00:00
|
|
|
#include <Parsers/ASTOptimizeQuery.h>
|
2019-10-08 18:42:22 +00:00
|
|
|
#include <Common/quoteString.h>
|
2020-11-09 16:05:40 +00:00
|
|
|
#include <IO/Operators.h>
|
2018-07-20 05:46:48 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
void ASTOptimizeQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "OPTIMIZE TABLE " << (settings.hilite ? hilite_none : "")
|
|
|
|
<< (!database.empty() ? backQuoteIfNeed(database) + "." : "") << backQuoteIfNeed(table);
|
|
|
|
|
|
|
|
formatOnCluster(settings);
|
|
|
|
|
|
|
|
if (partition)
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " PARTITION " << (settings.hilite ? hilite_none : "");
|
|
|
|
partition->formatImpl(settings, state, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (final)
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FINAL" << (settings.hilite ? hilite_none : "");
|
|
|
|
|
|
|
|
if (deduplicate)
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " DEDUPLICATE" << (settings.hilite ? hilite_none : "");
|
2020-12-01 09:10:12 +00:00
|
|
|
|
|
|
|
if (deduplicate_by_columns)
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " BY " << (settings.hilite ? hilite_none : "");
|
|
|
|
deduplicate_by_columns->formatImpl(settings, state, frame);
|
|
|
|
}
|
2018-07-20 05:46:48 +00:00
|
|
|
}
|
|
|
|
|
2018-07-24 19:05:23 +00:00
|
|
|
}
|