2017-04-21 12:39:28 +00:00
|
|
|
#include <Parsers/ASTQueryWithOnCluster.h>
|
|
|
|
#include <Parsers/queryToString.h>
|
|
|
|
#include <Parsers/CommonParsers.h>
|
|
|
|
#include <Parsers/ExpressionElementParsers.h>
|
2017-11-21 19:17:24 +00:00
|
|
|
#include <Parsers/parseIdentifierOrStringLiteral.h>
|
2017-04-21 12:39:28 +00:00
|
|
|
#include <Common/typeid_cast.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>
|
2017-04-21 12:39:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string ASTQueryWithOnCluster::getRewrittenQueryWithoutOnCluster(const std::string & new_database) const
|
|
|
|
{
|
|
|
|
return queryToString(getRewrittenASTWithoutOnCluster(new_database));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
bool ASTQueryWithOnCluster::parse(Pos & pos, std::string & cluster_str, Expected & expected)
|
2017-04-21 12:39:28 +00:00
|
|
|
{
|
2017-07-10 03:28:12 +00:00
|
|
|
if (!ParserKeyword{"CLUSTER"}.ignore(pos, expected))
|
2017-04-21 12:39:28 +00:00
|
|
|
return false;
|
|
|
|
|
2017-08-04 15:54:00 +00:00
|
|
|
return parseIdentifierOrStringLiteral(pos, expected, cluster_str);
|
2017-04-21 12:39:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ASTQueryWithOnCluster::formatOnCluster(const IAST::FormatSettings & settings) const
|
|
|
|
{
|
|
|
|
if (!cluster.empty())
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? IAST::hilite_keyword : "") << " ON CLUSTER " << (settings.hilite ? IAST::hilite_none : "")
|
|
|
|
<< backQuoteIfNeed(cluster);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|