1 | #pragma once |
---|---|
2 | |
3 | #include <Parsers/ASTQueryWithTableAndOutput.h> |
4 | #include <Parsers/ASTPartition.h> |
5 | #include <Common/quoteString.h> |
6 | |
7 | |
8 | namespace DB |
9 | { |
10 | |
11 | struct ASTCheckQuery : public ASTQueryWithTableAndOutput |
12 | { |
13 | |
14 | ASTPtr partition; |
15 | |
16 | /** Get the text that identifies this element. */ |
17 | String getID(char delim) const override { return "CheckQuery"+ (delim + database) + delim + table; } |
18 | |
19 | ASTPtr clone() const override |
20 | { |
21 | auto res = std::make_shared<ASTCheckQuery>(*this); |
22 | res->children.clear(); |
23 | cloneOutputOptions(*res); |
24 | return res; |
25 | } |
26 | |
27 | protected: |
28 | void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override |
29 | { |
30 | std::string nl_or_nothing = settings.one_line ? "": "\n"; |
31 | |
32 | std::string indent_str = settings.one_line ? "": std::string(4 * frame.indent, ' '); |
33 | std::string nl_or_ws = settings.one_line ? " ": "\n"; |
34 | |
35 | settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "CHECK TABLE "<< (settings.hilite ? hilite_none : ""); |
36 | |
37 | if (!table.empty()) |
38 | { |
39 | if (!database.empty()) |
40 | { |
41 | settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << backQuoteIfNeed(database) << (settings.hilite ? hilite_none : ""); |
42 | settings.ostr << "."; |
43 | } |
44 | settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << backQuoteIfNeed(table) << (settings.hilite ? hilite_none : ""); |
45 | } |
46 | |
47 | if (partition) |
48 | { |
49 | settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << " PARTITION "<< (settings.hilite ? hilite_none : ""); |
50 | partition->formatImpl(settings, state, frame); |
51 | } |
52 | } |
53 | }; |
54 | |
55 | } |
56 |