update

fix
This commit is contained in:
feng lv 2021-07-02 02:11:28 +00:00
parent 9ad405cae8
commit 3789e23dc9
4 changed files with 15 additions and 11 deletions

View File

@ -49,7 +49,7 @@ public:
const ASTPtr & left_in_operand, ContextPtr query_context, const StorageMetadataPtr & metadata_snapshot) const override;
private:
using DbToTableSetMap = std::unordered_map<String, std::unordered_set<String>>;
using DbToTableSetMap = std::map<String, std::set<String>>;
std::optional<OptimizedRegularExpression> source_database_regexp;
std::optional<OptimizedRegularExpression> source_table_regexp;

View File

@ -106,10 +106,13 @@ ColumnsDescription TableFunctionMerge::getActualTableStructure(ContextPtr contex
{
for (const auto & db_with_tables : getSourceDatabasesAndTables(context))
{
auto storage = DatabaseCatalog::instance().tryGetTable(StorageID{db_with_tables.first, *db_with_tables.second.begin()}, context);
for (const auto & table : db_with_tables.second)
{
auto storage = DatabaseCatalog::instance().tryGetTable(StorageID{db_with_tables.first, table}, context);
if (storage)
return ColumnsDescription{storage->getInMemoryMetadataPtr()->getColumns().getAllPhysical()};
}
}
throwNoTablesMatchRegexp(source_database_name_or_regexp, source_table_regexp);
}
@ -130,7 +133,7 @@ StoragePtr TableFunctionMerge::executeImpl(const ASTPtr & /*ast_function*/, Cont
return res;
}
NameSet
TableFunctionMerge::TableSet
TableFunctionMerge::getMatchedTablesWithAccess(const String & database_name, const String & table_regexp, const ContextPtr & context)
{
OptimizedRegularExpression table_re(table_regexp);
@ -144,7 +147,7 @@ TableFunctionMerge::getMatchedTablesWithAccess(const String & database_name, con
bool granted_show_on_all_tables = access->isGranted(AccessType::SHOW_TABLES, database_name);
bool granted_select_on_all_tables = access->isGranted(AccessType::SELECT, database_name);
NameSet tables;
TableSet tables;
for (auto it = database->getTablesIterator(context, table_name_match); it->isValid(); it->next())
{

View File

@ -20,11 +20,12 @@ 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"; }
using DbToTableSetMap = std::unordered_map<String, std::unordered_set<String>>;
using TableSet = std::set<String>;
using DbToTableSetMap = std::map<String, TableSet>;
const DbToTableSetMap & getSourceDatabasesAndTables(ContextPtr context) const;
ColumnsDescription getActualTableStructure(ContextPtr context) const override;
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
static NameSet getMatchedTablesWithAccess(const String & database_name, const String & table_regexp, const ContextPtr & context);
static TableSet getMatchedTablesWithAccess(const String & database_name, const String & table_regexp, const ContextPtr & context);
String source_database_name_or_regexp;
String source_table_regexp;

View File

@ -49,9 +49,9 @@
2018-08-01 100
2018-08-01 200
--------------Implicit type conversion------------
2018-08-01 -1
2018-08-01 1
2018-08-01 -1
2018-08-01 1
2018-08-01 18446744073709551615
2018-08-01 1
2018-08-01 18446744073709551615
2018-08-01 1
2018-08-01 1