ClickHouse/src/TableFunctions/TableFunctionMerge.h

33 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
#include <TableFunctions/ITableFunction.h>
namespace DB
{
/* 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.
*/
class TableFunctionMerge : public ITableFunction
{
public:
static constexpr auto name = "merge";
std::string getName() const override { return name; }
private:
StoragePtr executeImpl(const ASTPtr & ast_function, ContextPtr context, const std::string & table_name, ColumnsDescription cached_columns) const override;
const char * getStorageTypeName() const override { return "Merge"; }
2021-06-04 14:48:48 +00:00
const std::unordered_map<String, std::unordered_set<String>> & getSourceDatabasesAndTables(ContextPtr context) const;
ColumnsDescription getActualTableStructure(ContextPtr context) const override;
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
2021-06-04 14:48:48 +00:00
String source_database_regexp;
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;
};
}