mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-05 05:52:05 +00:00
made index parser
This commit is contained in:
parent
7b0fcecdf2
commit
6f986495dd
51
dbms/src/Parsers/ASTIndexDeclaration.h
Normal file
51
dbms/src/Parsers/ASTIndexDeclaration.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <Core/Types.h>
|
||||
#include <Parsers/IAST.h>
|
||||
#include <Parsers/ASTExpressionList.h>
|
||||
#include <Parsers/ASTFunction.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
|
||||
/** Index name(expr) TYPE typename(args) in create query
|
||||
*/
|
||||
class ASTIndexQuery : public IAST
|
||||
{
|
||||
public:
|
||||
struct Index
|
||||
{
|
||||
String name;
|
||||
ASTPtr expression_list;
|
||||
ASTFunction type;
|
||||
};
|
||||
|
||||
using Indexes = std::vector<Index>;
|
||||
Indexes indexes;
|
||||
|
||||
/** Get the text that identifies this element. */
|
||||
String getID(char) const override { return "Index"; }
|
||||
|
||||
ASTPtr clone() const override { return std::make_shared<ASTIndexQuery>(*this); }
|
||||
|
||||
void formatImpl(const FormatSettings & s, FormatState &state, FormatStateStacked frame) const override
|
||||
{
|
||||
for (ASTIndexQuery::Indexes::const_iterator it = indexes.begin(); it != indexes.end(); ++it)
|
||||
{
|
||||
if (it != indexes.begin())
|
||||
s.ostr << s.nl_or_ws;
|
||||
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << "INDEX" << (s.hilite ? hilite_none : "") << " " << it->name;
|
||||
s.ostr << "(";
|
||||
it->expression_list->formatImpl(s, state, frame);
|
||||
s.ostr << ") " << (s.hilite ? hilite_keyword : "") << "TYPE" << (s.hilite ? hilite_none : "");
|
||||
it->type.formatImpl(s, state, frame);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user