MCPcopy Create free account
hub / github.com/ByConity/ByConity / createInsertToRemoteTableQuery

Function createInsertToRemoteTableQuery

src/Storages/StorageDistributed.cpp:197–209  ·  view source on GitHub ↗

The columns list in the original INSERT query is incorrect because inserted blocks are transformed to the form of the sample block of the Distributed table. So we rewrite it and add all columns from the sample block instead.

Source from the content-addressed store, hash-verified

195/// to the form of the sample block of the Distributed table. So we rewrite it and add all columns from
196/// the sample block instead.
197ASTPtr createInsertToRemoteTableQuery(const std::string & database, const std::string & table, const Block & sample_block)
198{
199 auto query = std::make_shared<ASTInsertQuery>();
200 query->table_id = StorageID(database, table);
201
202 auto columns = std::make_shared<ASTExpressionList>();
203 query->columns = columns;
204 query->children.push_back(columns);
205 for (const auto & col : sample_block)
206 columns->children.push_back(std::make_shared<ASTIdentifier>(col.name));
207
208 return query;
209}
210
211/// Calculate maximum number in file names in directory and all subdirectories.
212/// To ensure global order of data blocks yet to be sent across server restarts.

Callers 1

writeMethod · 0.85

Calls 2

StorageIDClass · 0.70
push_backMethod · 0.45

Tested by

no test coverage detected