2020-06-01 21:11:08 +00:00
|
|
|
#include <Parsers/ASTIndexDeclaration.h>
|
2020-12-16 21:44:05 +00:00
|
|
|
|
2020-06-01 21:11:08 +00:00
|
|
|
#include <Common/quoteString.h>
|
2020-11-09 16:05:40 +00:00
|
|
|
#include <IO/Operators.h>
|
2020-12-16 21:44:05 +00:00
|
|
|
#include <Parsers/ASTFunction.h>
|
2020-06-01 21:11:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
ASTPtr ASTIndexDeclaration::clone() const
|
|
|
|
{
|
|
|
|
auto res = std::make_shared<ASTIndexDeclaration>();
|
|
|
|
|
|
|
|
res->name = name;
|
|
|
|
res->granularity = granularity;
|
|
|
|
|
|
|
|
if (expr)
|
|
|
|
res->set(res->expr, expr->clone());
|
|
|
|
if (type)
|
|
|
|
res->set(res->type, type->clone());
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ASTIndexDeclaration::formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const
|
|
|
|
{
|
2022-06-29 11:10:30 +00:00
|
|
|
if (part_of_create_index_query)
|
2022-03-10 07:31:27 +00:00
|
|
|
{
|
2022-06-16 09:58:14 +00:00
|
|
|
s.ostr << "(";
|
2022-03-10 07:31:27 +00:00
|
|
|
expr->formatImpl(s, state, frame);
|
2022-06-16 09:58:14 +00:00
|
|
|
s.ostr << ")";
|
2022-03-10 07:31:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-06-16 09:58:14 +00:00
|
|
|
s.ostr << backQuoteIfNeed(name);
|
|
|
|
s.ostr << " ";
|
2022-03-10 07:31:27 +00:00
|
|
|
expr->formatImpl(s, state, frame);
|
|
|
|
}
|
2022-06-16 09:58:14 +00:00
|
|
|
|
2020-06-01 21:11:08 +00:00
|
|
|
s.ostr << (s.hilite ? hilite_keyword : "") << " TYPE " << (s.hilite ? hilite_none : "");
|
|
|
|
type->formatImpl(s, state, frame);
|
|
|
|
s.ostr << (s.hilite ? hilite_keyword : "") << " GRANULARITY " << (s.hilite ? hilite_none : "");
|
|
|
|
s.ostr << granularity;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|