ClickHouse/src/Parsers/ASTDeleteQuery.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.2 KiB
C++
Raw Normal View History

#include <Parsers/ASTDeleteQuery.h>
#include <Common/quoteString.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 (predicate)
{
res->predicate = predicate->clone();
res->children.push_back(res->predicate);
}
2022-09-19 18:58:21 +00:00
if (settings_ast)
{
res->settings_ast = settings_ast->clone();
res->children.push_back(res->settings_ast);
}
cloneTableOptions(*res);
return res;
}
void ASTDeleteQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << "DELETE FROM " << (settings.hilite ? hilite_none : "");
if (database)
{
settings.ostr << backQuoteIfNeed(getDatabase());
settings.ostr << ".";
}
settings.ostr << backQuoteIfNeed(getTable());
2023-01-30 15:42:52 +00:00
formatOnCluster(settings);
settings.ostr << (settings.hilite ? hilite_keyword : "") << " WHERE " << (settings.hilite ? hilite_none : "");
predicate->formatImpl(settings, state, frame);
}
}