2018-12-25 18:42:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-02 16:04:44 +00:00
|
|
|
#include <Core/Field.h>
|
2018-12-25 18:42:43 +00:00
|
|
|
#include <Core/Types.h>
|
2019-01-02 16:04:44 +00:00
|
|
|
#include <Common/FieldVisitors.h>
|
2018-12-25 18:42:43 +00:00
|
|
|
#include <Parsers/ASTExpressionList.h>
|
|
|
|
#include <Parsers/ASTFunction.h>
|
2019-01-02 16:04:44 +00:00
|
|
|
#include <Parsers/IAST.h>
|
2018-12-25 18:42:43 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-01-08 11:04:25 +00:00
|
|
|
/** name BY expr TYPE typename(args) GRANULARITY int in create query
|
2018-12-25 18:42:43 +00:00
|
|
|
*/
|
2018-12-25 18:45:08 +00:00
|
|
|
class ASTIndexDeclaration : public IAST
|
2018-12-25 18:42:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-12-25 18:45:08 +00:00
|
|
|
String name;
|
|
|
|
IAST * expr;
|
|
|
|
ASTFunction * type;
|
2019-01-02 16:04:44 +00:00
|
|
|
Field granularity;
|
2018-12-25 18:42:43 +00:00
|
|
|
|
|
|
|
/** Get the text that identifies this element. */
|
|
|
|
String getID(char) const override { return "Index"; }
|
|
|
|
|
2018-12-25 18:45:08 +00:00
|
|
|
ASTPtr clone() const override {
|
2019-01-08 09:38:46 +00:00
|
|
|
auto res = std::make_shared<ASTIndexDeclaration>();
|
|
|
|
|
|
|
|
res->name = name;
|
|
|
|
res->granularity = granularity;
|
2018-12-25 18:45:08 +00:00
|
|
|
|
|
|
|
if (expr)
|
|
|
|
res->set(res->expr, expr->clone());
|
|
|
|
if (type)
|
|
|
|
res->set(res->type, type->clone());
|
|
|
|
return res;
|
|
|
|
}
|
2018-12-25 18:42:43 +00:00
|
|
|
|
|
|
|
void formatImpl(const FormatSettings & s, FormatState &state, FormatStateStacked frame) const override
|
|
|
|
{
|
2018-12-25 18:45:08 +00:00
|
|
|
s.ostr << name;
|
|
|
|
s.ostr << (s.hilite ? hilite_keyword : "") << " BY " << (s.hilite ? hilite_none : "");
|
|
|
|
expr->formatImpl(s, state, frame);
|
|
|
|
s.ostr << (s.hilite ? hilite_keyword : "") << " TYPE " << (s.hilite ? hilite_none : "");
|
|
|
|
type->formatImpl(s, state, frame);
|
2019-01-02 16:04:44 +00:00
|
|
|
s.ostr << (s.hilite ? hilite_keyword : "") << " GRANULARITY " << (s.hilite ? hilite_none : "");
|
|
|
|
s.ostr << applyVisitor(FieldVisitorToString(), granularity);
|
2018-12-25 18:42:43 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|