2014-01-28 16:45:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <TableFunctions/ITableFunction.h>
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-05-23 18:44:36 +00:00
|
|
|
/* merge (db_name, tables_regexp) - creates a temporary StorageMerge.
|
2017-04-16 15:00:33 +00:00
|
|
|
* The structure of the table is taken from the first table that came up, suitable for regexp.
|
|
|
|
* If there is no such table, an exception is thrown.
|
2014-01-28 16:45:10 +00:00
|
|
|
*/
|
2017-06-10 09:04:31 +00:00
|
|
|
class TableFunctionMerge : public ITableFunction
|
2014-01-28 16:45:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-06-10 09:04:31 +00:00
|
|
|
static constexpr auto name = "merge";
|
|
|
|
std::string getName() const override { return name; }
|
2018-03-02 05:03:28 +00:00
|
|
|
private:
|
2021-04-10 23:33:54 +00:00
|
|
|
StoragePtr executeImpl(const ASTPtr & ast_function, ContextPtr context, const std::string & table_name, ColumnsDescription cached_columns) const override;
|
2020-04-06 05:19:40 +00:00
|
|
|
const char * getStorageTypeName() const override { return "Merge"; }
|
2020-10-14 12:19:29 +00:00
|
|
|
|
2021-06-04 14:48:48 +00:00
|
|
|
const std::unordered_map<String, std::unordered_set<String>> & getSourceDatabasesAndTables(ContextPtr context) const;
|
2021-04-10 23:33:54 +00:00
|
|
|
ColumnsDescription getActualTableStructure(ContextPtr context) const override;
|
|
|
|
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
|
2020-10-14 12:19:29 +00:00
|
|
|
|
2021-06-04 14:48:48 +00:00
|
|
|
String source_database_regexp;
|
2020-12-10 20:16:53 +00:00
|
|
|
String source_table_regexp;
|
2021-06-04 14:48:48 +00:00
|
|
|
mutable std::optional<std::unordered_map<String, std::unordered_set<String>>> source_databases_and_tables;
|
2014-01-28 16:45:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|