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,
|
2019-02-11 19:53:55 +00:00
|
|
|
AnalyzedSyntax,
|
2018-09-21 15:20:23 +00:00
|
|
|
};
|
|
|
|
|
2019-02-11 19:53:55 +00:00
|
|
|
ASTExplainQuery(ExplainKind kind_)
|
2018-09-21 15:20:23 +00:00
|
|
|
: kind(kind_)
|
|
|
|
{}
|
|
|
|
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char delim) const override { return "Explain" + (delim + toString(kind)); }
|
2019-02-11 19:53:55 +00:00
|
|
|
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";
|
2019-02-11 19:53:55 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|