2013-02-21 10:02:33 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/Parsers/IAST.h>
|
|
|
|
|
#include <DB/Parsers/ASTQueryWithOutput.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Запрос с указанием названия таблицы и, возможно, БД и секцией FORMAT.
|
|
|
|
|
*/
|
|
|
|
|
class ASTQueryWithTableAndOutput : public ASTQueryWithOutput
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
String database;
|
|
|
|
|
String table;
|
|
|
|
|
|
2014-12-17 15:26:24 +00:00
|
|
|
|
ASTQueryWithTableAndOutput() = default;
|
|
|
|
|
ASTQueryWithTableAndOutput(const StringRange range_) : ASTQueryWithOutput(range_) {}
|
2013-02-21 10:02:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Объявляет класс-наследник ASTQueryWithTableAndOutput с реализованными методами getID и clone.
|
|
|
|
|
#define DEFINE_AST_QUERY_WITH_TABLE_AND_OUTPUT(Name, ID) \
|
|
|
|
|
class Name : public ASTQueryWithTableAndOutput \
|
|
|
|
|
{ \
|
|
|
|
|
public: \
|
2014-12-17 15:26:24 +00:00
|
|
|
|
Name() = default; \
|
|
|
|
|
Name(const StringRange range_) : ASTQueryWithTableAndOutput(range_) {} \
|
|
|
|
|
String getID() const override { return ID"_" + database + "_" + table; }; \
|
2013-02-21 10:02:33 +00:00
|
|
|
|
\
|
2014-12-17 15:26:24 +00:00
|
|
|
|
ASTPtr clone() const override \
|
2013-02-21 10:02:33 +00:00
|
|
|
|
{ \
|
|
|
|
|
Name * res = new Name(*this); \
|
2014-12-17 15:26:24 +00:00
|
|
|
|
ASTPtr ptr{res}; \
|
2013-02-21 10:02:33 +00:00
|
|
|
|
res->children.clear(); \
|
|
|
|
|
if (format) \
|
|
|
|
|
{ \
|
|
|
|
|
res->format = format->clone(); \
|
|
|
|
|
res->children.push_back(res->format); \
|
|
|
|
|
} \
|
2014-12-17 15:26:24 +00:00
|
|
|
|
return ptr; \
|
2013-02-21 10:02:33 +00:00
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|