mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
#include <Parsers/ASTOptimizeQuery.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
|
|
ASTPtr ASTOptimizeQuery::getRewrittenASTWithoutOnCluster(const std::string & new_database) const
|
|
{
|
|
auto query_ptr = clone();
|
|
ASTOptimizeQuery & query = static_cast<ASTOptimizeQuery &>(*query_ptr);
|
|
|
|
query.cluster.clear();
|
|
if (query.database.empty())
|
|
query.database = new_database;
|
|
|
|
return query_ptr;
|
|
}
|
|
|
|
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 : "");
|
|
}
|
|
|
|
}
|