ClickHouse/dbms/src/Parsers/ASTExplainQuery.h

50 lines
1.1 KiB
C++
Raw Normal View History

2018-09-21 15:20:23 +00:00
#pragma once
#include <Parsers/IAST.h>
namespace DB
{
/// AST, EXPLAIN or other query with meaning of explanation query instead of execution
class ASTExplainQuery : public IAST
{
public:
enum ExplainKind
{
ParsedAST,
AnalyzedSyntax,
2018-09-21 15:20:23 +00:00
};
ASTExplainQuery(ExplainKind kind_)
2018-09-21 15:20:23 +00:00
: kind(kind_)
{}
String getID(char delim) const override { return "Explain" + (delim + toString(kind)); }
ExplainKind getKind() const { return kind; }
2018-09-21 15:20:23 +00:00
ASTPtr clone() const override { return std::make_shared<ASTExplainQuery>(*this); }
protected:
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << toString(kind) << (settings.hilite ? hilite_none : "");
}
private:
ExplainKind kind;
static String toString(ExplainKind kind)
{
switch (kind)
{
case ParsedAST: return "ParsedAST";
case AnalyzedSyntax: return "AnalyzedSyntax";
2018-09-21 15:20:23 +00:00
}
2019-02-15 10:15:56 +00:00
__builtin_unreachable();
2018-09-21 15:20:23 +00:00
}
};
}