Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of using ExternalLoader in dictionary DDL. #8055

Merged

Conversation

vitlibar
Copy link
Member

@vitlibar vitlibar commented Dec 5, 2019

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category:

  • Non-significant (changelog entry is not needed)

Instead of using ExternalLoader::reload() now it's used reloadConfig() which reloads only what necessary. Functions attachDictionary() and detachDictionary() are simplified and have lesser number of parameters. Instead of injecting into LoadablesConfigReader's internals for creating dictionary a temp repository is used.

@vitlibar vitlibar force-pushed the more-accurate-using-load-reload branch 3 times, most recently from de72381 to 44ccfbf Compare December 5, 2019 19:26
@alesapin alesapin self-assigned this Dec 6, 2019
@vitlibar vitlibar force-pushed the more-accurate-using-load-reload branch from 44ccfbf to 2e7a246 Compare December 12, 2019 18:43
@vitlibar vitlibar changed the title More accurate using of ExternalLoader::load() & reload(). Refactoring of using ExternalLoader in dictionary DDL. Dec 12, 2019
Instead of using ExternalLoader::reload() now it's used reloadConfig() which reloads only what necessary.
Functions attachDictionary() and detachDictionary() are simplified and have lesser number of parameters.
Instead of injecting into LoadablesConfigReader's internals for creating dictionary a temp repository is used.
@vitlibar vitlibar force-pushed the more-accurate-using-load-reload branch from 2e7a246 to 4c15700 Compare December 12, 2019 18:46
@alexey-milovidov alexey-milovidov merged commit 3fa3166 into ClickHouse:master Dec 15, 2019
"Dictionary " + full_name + " already exists.",
ErrorCodes::DICTIONARY_ALREADY_EXISTS);
if (!dictionaries.emplace(dictionary_name).second)
throw Exception("Dictionary " + full_name + " already exists.", ErrorCodes::DICTIONARY_ALREADY_EXISTS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we removed this check?

Copy link
Member Author

@vitlibar vitlibar Dec 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createDictionary() adds a temp metadata file with a dictionary to ExternalLoader, then loads the dictionary (if lazy_load == false), then calls attachDictionary(). At the moment when attachDictionary() is called the dictionary could be already loaded. I don't think this check was very useful before anyway.

@@ -427,7 +427,8 @@ DictionaryConfigurationPtr getDictionaryConfigurationFromAST(const ASTCreateQuer

AutoPtr<Poco::XML::Element> name_element(xml_document->createElement("name"));
current_dictionary->appendChild(name_element);
AutoPtr<Text> name(xml_document->createTextNode(query.database + "." + query.table));
String full_name = (!database_name.empty() ? database_name : query.database) + "." + query.table;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@vitlibar vitlibar Dec 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's substituted, but the result of that substitution (i.e. database's name) isn't passed to createDictionary(). Seems it's better to set create.database there than the current solution, I'll simplify the code in a separate PR.


namespace DB
{
/// A config repository filled with preset loadables used by ExternalLoader.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't help.

Copy link
Member Author

@vitlibar vitlibar Dec 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll rename this class to something like ExternalLoaderTempConfigRepository and write a more detailed comment in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants