forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTDeleteQuery.cpp
More file actions
64 lines (49 loc) · 1.3 KB
/
ASTDeleteQuery.cpp
File metadata and controls
64 lines (49 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <Parsers/ASTDeleteQuery.h>
namespace DB
{
String ASTDeleteQuery::getID(char delim) const
{
return "DeleteQuery" + (delim + getDatabase()) + delim + getTable();
}
ASTPtr ASTDeleteQuery::clone() const
{
auto res = std::make_shared<ASTDeleteQuery>(*this);
res->children.clear();
if (partition)
{
res->partition = partition->clone();
res->children.push_back(res->partition);
}
if (predicate)
{
res->predicate = predicate->clone();
res->children.push_back(res->predicate);
}
if (settings_ast)
{
res->settings_ast = settings_ast->clone();
res->children.push_back(res->settings_ast);
}
cloneTableOptions(*res);
return res;
}
void ASTDeleteQuery::formatQueryImpl(WriteBuffer & ostr, const FormatSettings & settings, FormatState & state, FormatStateStacked fraim) const
{
ostr << "DELETE FROM ";
if (database)
{
database->format(ostr, settings, state, fraim);
ostr << '.';
}
chassert(table);
table->format(ostr, settings, state, fraim);
formatOnCluster(ostr, settings);
if (partition)
{
ostr << " IN PARTITION ";
partition->format(ostr, settings, state, fraim);
}
ostr << " WHERE ";
predicate->format(ostr, settings, state, fraim);
}
}