ClickHouse/src/Parsers/ASTInsertQuery.h

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

79 lines
2.5 KiB
C++
Raw Normal View History

2011-10-30 05:19:41 +00:00
#pragma once
2020-03-13 10:30:55 +00:00
#include <Interpreters/StorageID.h>
#include <Parsers/IAST.h>
2011-10-30 05:19:41 +00:00
namespace DB
{
2021-02-15 18:57:35 +00:00
class ReadBuffer;
2011-10-30 05:19:41 +00:00
/// INSERT query
2011-10-30 05:19:41 +00:00
class ASTInsertQuery : public IAST
{
public:
2020-03-02 20:23:58 +00:00
StorageID table_id = StorageID::createEmpty();
2021-10-12 23:51:11 +00:00
ASTPtr database;
ASTPtr table;
2011-10-30 05:19:41 +00:00
ASTPtr columns;
String format;
ASTPtr table_function;
2021-04-14 08:00:17 +00:00
ASTPtr partition_by;
ASTPtr settings_ast;
2021-03-04 11:10:21 +00:00
ASTPtr select;
ASTPtr watch;
ASTPtr infile;
ASTPtr compression;
2021-03-04 11:10:21 +00:00
/// Data inlined into query
2014-04-08 07:31:51 +00:00
const char * data = nullptr;
const char * end = nullptr;
/// Data from buffer to insert after inlined one - may be nullptr.
ReadBuffer * tail = nullptr;
2023-06-20 09:37:56 +00:00
bool async_insert_flush = false;
2021-10-12 23:51:11 +00:00
String getDatabase() const;
String getTable() const;
void setDatabase(const String & name);
void setTable(const String & name);
bool hasInlinedData() const { return data || tail; }
2019-02-08 13:24:24 +00:00
/// Try to find table function input() in SELECT part
2019-05-30 21:33:06 +00:00
void tryFindInputFunction(ASTPtr & input_function) const;
2017-05-27 17:27:16 +00:00
/** Get the text that identifies this element. */
2020-03-02 20:23:58 +00:00
String getID(char delim) const override { return "InsertQuery" + (delim + table_id.database_name) + delim + table_id.table_name; }
2014-12-17 15:26:24 +00:00
ASTPtr clone() const override
2011-12-12 06:15:34 +00:00
{
auto res = std::make_shared<ASTInsertQuery>(*this);
2011-12-12 06:15:34 +00:00
res->children.clear();
2021-10-12 23:51:11 +00:00
if (database) { res->database = database->clone(); res->children.push_back(res->database); }
2021-10-15 08:41:25 +00:00
if (table) { res->table = table->clone(); res->children.push_back(res->table); }
if (columns) { res->columns = columns->clone(); res->children.push_back(res->columns); }
2018-11-26 00:56:50 +00:00
if (select) { res->select = select->clone(); res->children.push_back(res->select); }
if (watch) { res->watch = watch->clone(); res->children.push_back(res->watch); }
if (table_function) { res->table_function = table_function->clone(); res->children.push_back(res->table_function); }
2021-04-14 08:00:17 +00:00
if (partition_by) { res->partition_by = partition_by->clone(); res->children.push_back(res->partition_by); }
if (settings_ast) { res->settings_ast = settings_ast->clone(); res->children.push_back(res->settings_ast); }
return res;
2011-12-12 06:15:34 +00:00
}
2023-06-20 09:37:56 +00:00
QueryKind getQueryKind() const override { return async_insert_flush ? QueryKind::AsyncInsertFlush : QueryKind::Insert; }
2021-08-04 14:09:23 +00:00
protected:
2016-11-20 12:43:20 +00:00
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
2021-08-31 02:16:02 +00:00
void updateTreeHashImpl(SipHash & hash_state) const override;
2011-10-30 05:19:41 +00:00
};
}