ClickHouse/dbms/Parsers/ASTQueryWithTableAndOutput.h

49 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <Parsers/IAST.h>
#include <Parsers/ASTQueryWithOutput.h>
2019-12-27 19:30:22 +00:00
#include <Core/UUID.h>
namespace DB
{
2017-05-27 17:27:16 +00:00
/** Query specifying table name and, possibly, the database and the FORMAT section.
*/
class ASTQueryWithTableAndOutput : public ASTQueryWithOutput
{
public:
String database;
String table;
2020-03-03 19:53:18 +00:00
UUID uuid = UUIDHelpers::Nil;
bool temporary{false};
protected:
void formatHelper(const FormatSettings & settings, const char * name) const;
};
template <typename AstIDAndQueryNames>
class ASTQueryWithTableAndOutputImpl : public ASTQueryWithTableAndOutput
{
public:
String getID(char delim) const override { return AstIDAndQueryNames::ID + (delim + database) + delim + table; }
ASTPtr clone() const override
{
auto res = std::make_shared<ASTQueryWithTableAndOutputImpl<AstIDAndQueryNames>>(*this);
res->children.clear();
cloneOutputOptions(*res);
return res;
}
protected:
2017-12-11 18:40:28 +00:00
void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
{
formatHelper(settings, temporary ? AstIDAndQueryNames::QueryTemporary : AstIDAndQueryNames::Query);
}
};
}