Fixed tests

This commit is contained in:
Maksim Kita 2021-03-18 17:03:22 +03:00
parent 0f95bcac0b
commit a65bfaeab3
4 changed files with 23 additions and 7 deletions

View File

@ -81,9 +81,9 @@ public:
{
String resolved_name = DatabaseCatalog::instance().resolveDictionaryName(dictionary_name);
auto dict = external_loader.tryGetDictionary(resolved_name);
bool can_load_dictionary = external_loader.hasDictionary(resolved_name);
if (!dict)
if (!can_load_dictionary)
{
/// If dictionary not found. And database was not implicitly specified
/// we can qualify dictionary name with current database name.
@ -92,12 +92,10 @@ public:
{
String dictionary_name_with_database = context.getCurrentDatabase() + '.' + dictionary_name;
resolved_name = DatabaseCatalog::instance().resolveDictionaryName(dictionary_name_with_database);
dict = external_loader.tryGetDictionary(resolved_name);
}
}
if (!dict)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "External dictionary ({}) not found", dictionary_name);
auto dict = external_loader.getDictionary(resolved_name);
if (!access_checked)
{
@ -330,7 +328,6 @@ public:
DataTypes types;
auto current_database_name = helper.context.getCurrentDatabase();
auto dictionary_structure = helper.getDictionaryStructure(dictionary_name);
for (auto & attribute_name : attribute_names)

View File

@ -16,7 +16,7 @@ public:
using DictPtr = std::shared_ptr<const IDictionaryBase>;
/// Dictionaries will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds.
ExternalDictionariesLoader(Context & context_);
explicit ExternalDictionariesLoader(Context & context_);
DictPtr getDictionary(const std::string & name) const
{
@ -28,6 +28,11 @@ public:
return std::static_pointer_cast<const IDictionaryBase>(tryLoad(name));
}
bool hasDictionary(const std::string & name) const
{
return has(name);
}
static DictionaryStructure getDictionaryStructure(const Poco::Util::AbstractConfiguration & config, const std::string & key_in_config = "dictionary");
static DictionaryStructure getDictionaryStructure(const ObjectConfig & config);

View File

@ -625,6 +625,12 @@ public:
return collectLoadResults<ReturnType>(filter);
}
bool has(const String & name) const
{
std::lock_guard lock{mutex};
return infos.contains(name);
}
/// Starts reloading all the object which update time is earlier than now.
/// The function doesn't touch the objects which were never tried to load.
void reloadOutdated()
@ -1391,6 +1397,11 @@ ReturnType ExternalLoader::reloadAllTriedToLoad() const
return loadOrReload<ReturnType>([&names](const String & name) { return names.count(name); });
}
bool ExternalLoader::has(const String & name) const
{
return loading_dispatcher->has(name);
}
Strings ExternalLoader::getAllTriedToLoadNames() const
{
return loading_dispatcher->getAllTriedToLoadNames();

View File

@ -196,6 +196,9 @@ public:
template <typename ReturnType = Loadables, typename = std::enable_if_t<is_vector_load_result_type<ReturnType>, void>>
ReturnType reloadAllTriedToLoad() const;
/// Check if object with name exists in configuration
bool has(const String & name) const;
/// Reloads all config repositories.
void reloadConfig() const;