Merge pull request #29201 from ClickHouse/follow_up_to_28373

Follow up to #28373
This commit is contained in:
tavplubix 2021-09-21 08:26:15 +03:00 committed by GitHub
commit 5f4c665c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,9 +106,11 @@ std::string ExternalDictionariesLoader::resolveDictionaryNameFromDatabaseCatalog
/// Try to split name and get id from associated StorageDictionary. /// Try to split name and get id from associated StorageDictionary.
/// If something went wrong, return name as is. /// If something went wrong, return name as is.
String res = name;
auto qualified_name = QualifiedTableName::tryParseFromString(name); auto qualified_name = QualifiedTableName::tryParseFromString(name);
if (!qualified_name) if (!qualified_name)
return name; return res;
if (qualified_name->database.empty()) if (qualified_name->database.empty())
{ {
@ -116,9 +118,10 @@ std::string ExternalDictionariesLoader::resolveDictionaryNameFromDatabaseCatalog
/// or it's an XML dictionary. /// or it's an XML dictionary.
bool is_xml_dictionary = has(name); bool is_xml_dictionary = has(name);
if (is_xml_dictionary) if (is_xml_dictionary)
return name; return res;
else
qualified_name->database = current_database_name; qualified_name->database = current_database_name;
res = current_database_name + '.' + name;
} }
auto [db, table] = DatabaseCatalog::instance().tryGetDatabaseAndTable( auto [db, table] = DatabaseCatalog::instance().tryGetDatabaseAndTable(
@ -126,13 +129,13 @@ std::string ExternalDictionariesLoader::resolveDictionaryNameFromDatabaseCatalog
const_pointer_cast<Context>(getContext())); const_pointer_cast<Context>(getContext()));
if (!db) if (!db)
return name; return res;
assert(table); assert(table);
if (db->getUUID() == UUIDHelpers::Nil) if (db->getUUID() == UUIDHelpers::Nil)
return name; return res;
if (table->getName() != "Dictionary") if (table->getName() != "Dictionary")
return name; return res;
return toString(table->getStorageID().uuid); return toString(table->getStorageID().uuid);
} }