MCPcopy Create free account
hub / github.com/ByConity/ByConity / parseImpl

Method parseImpl

src/Parsers/ParserSystemQuery.cpp:85–500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85bool ParserSystemQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected)
86{
87 if (!ParserKeyword{"SYSTEM"}.ignore(pos, expected))
88 return false;
89
90 using Type = ASTSystemQuery::Type;
91
92 auto res = std::make_shared<ASTSystemQuery>();
93
94 bool found = false;
95 for (int i = static_cast<int>(Type::UNKNOWN) + 1; i < static_cast<int>(Type::END); ++i)
96 {
97 Type t = static_cast<Type>(i);
98 if (ParserKeyword{ASTSystemQuery::typeToString(t)}.ignore(pos, expected))
99 {
100 res->type = t;
101 found = true;
102 }
103 }
104
105 if (!found)
106 return false;
107
108 // Parse integer
109 auto parse_uint = [](IParser::Pos & pos_, Expected & expected_, UInt64 & res_)
110 {
111 ASTPtr ast;
112 if (!ParserUnsignedInteger().parse(pos_, ast, expected_)) return false;
113 res_ = safeGet<UInt64>(ast->as<ASTLiteral>()->value);
114 return true;
115 };
116 ParserPartition parser_partition;
117 switch (res->type)
118 {
119 case Type::RELOAD_DICTIONARY:
120 {
121 if (!parseQueryWithOnClusterAndMaybeTable(res, pos, expected, /* require table = */ true, /* allow_string_literal = */ true))
122 return false;
123 break;
124 }
125 case Type::RELOAD_MODEL:
126 {
127 String cluster_str;
128 if (ParserKeyword{"ON"}.ignore(pos, expected))
129 {
130 if (!ASTQueryWithOnCluster::parse(pos, cluster_str, expected))
131 return false;
132 }
133 res->cluster = cluster_str;
134 ASTPtr ast;
135 if (ParserStringLiteral{}.parse(pos, ast, expected))
136 {
137 res->target_model = ast->as<ASTLiteral &>().value.safeGet<String>();
138 }
139 else
140 {
141 ParserIdentifier model_parser;
142 ASTPtr model;

Callers

nothing calls this directly

Calls 15

ParserStringLiteralClass · 0.85
get<UInt64>Method · 0.80
getTableIdMethod · 0.80
tryGetIdentifierNameIntoFunction · 0.70
typeToStringFunction · 0.50
parseFunction · 0.50
ignoreMethod · 0.45

Tested by

no test coverage detected