2013-02-21 10:02:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
#include <Parsers/ASTQueryWithOutput.h>
|
2019-12-27 19:30:22 +00:00
|
|
|
#include <Core/UUID.h>
|
2013-02-21 10:02:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2015-08-06 03:26:27 +00:00
|
|
|
|
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** Query specifying table name and, possibly, the database and the FORMAT section.
|
2019-06-29 16:58:32 +00:00
|
|
|
*/
|
2015-08-05 21:38:31 +00:00
|
|
|
class ASTQueryWithTableAndOutput : public ASTQueryWithOutput
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
String database;
|
|
|
|
String table;
|
2019-12-27 19:30:22 +00:00
|
|
|
UUID uuid;
|
2018-02-14 04:00:37 +00:00
|
|
|
bool temporary{false};
|
2015-08-05 21:38:31 +00:00
|
|
|
|
2015-08-06 03:26:27 +00:00
|
|
|
protected:
|
2019-06-29 16:58:32 +00:00
|
|
|
void formatHelper(const FormatSettings & settings, const char * name) const;
|
2015-08-05 21:38:31 +00:00
|
|
|
};
|
2015-08-06 03:26:27 +00:00
|
|
|
|
|
|
|
|
2017-11-01 14:34:05 +00:00
|
|
|
template <typename AstIDAndQueryNames>
|
|
|
|
class ASTQueryWithTableAndOutputImpl : public ASTQueryWithTableAndOutput
|
|
|
|
{
|
|
|
|
public:
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char delim) const override { return AstIDAndQueryNames::ID + (delim + database) + delim + table; }
|
2017-11-01 14:34:05 +00:00
|
|
|
|
|
|
|
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
|
2017-11-01 14:34:05 +00:00
|
|
|
{
|
2019-06-29 16:58:32 +00:00
|
|
|
formatHelper(settings, temporary ? AstIDAndQueryNames::QueryTemporary : AstIDAndQueryNames::Query);
|
2017-11-01 14:34:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-21 10:02:33 +00:00
|
|
|
}
|