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

Function parseQueryWithOnClusterAndMaybeTable

src/Parsers/ParserSystemQuery.cpp:43–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41{
42
43static bool parseQueryWithOnClusterAndMaybeTable(std::shared_ptr<ASTSystemQuery> & res, IParser::Pos & pos,
44 Expected & expected, bool require_table, bool allow_string_literal)
45{
46 /// Better form for user: SYSTEM <ACTION> table ON CLUSTER cluster
47 /// Query rewritten form + form while executing on cluster: SYSTEM <ACTION> ON CLUSTER cluster table
48 /// Need to support both
49 String cluster;
50 bool parsed_on_cluster = false;
51
52 if (ParserKeyword{"ON"}.ignore(pos, expected))
53 {
54 if (!ASTQueryWithOnCluster::parse(pos, cluster, expected))
55 return false;
56 parsed_on_cluster = true;
57 }
58
59 bool parsed_table = false;
60 if (allow_string_literal)
61 {
62 ASTPtr ast;
63 if (ParserStringLiteral{}.parse(pos, ast, expected))
64 {
65 res->database = {};
66 res->table = ast->as<ASTLiteral &>().value.safeGet<String>();
67 parsed_table = true;
68 }
69 }
70
71 if (!parsed_table)
72 parsed_table = parseDatabaseAndTableName(pos, expected, res->database, res->table);
73
74 if (!parsed_table && require_table)
75 return false;
76
77 if (!parsed_on_cluster && ParserKeyword{"ON"}.ignore(pos, expected))
78 if (!ASTQueryWithOnCluster::parse(pos, cluster, expected))
79 return false;
80
81 res->cluster = cluster;
82 return true;
83}
84
85bool ParserSystemQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected)
86{

Callers 1

parseImplMethod · 0.85

Calls 4

parseFunction · 0.50
ignoreMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected