-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Support {database} and {table} macros in ReplicatedMergeTree [CLICKHOUSE-3897] #3251
Conversation
@@ -29,7 +30,7 @@ class Macros | |||
/** Replace the substring of the form {macro_name} with the value for macro_name, obtained from the config file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing update of comment.
dbms/src/Common/Macros.cpp
Outdated
auto it = macros.find(macro_name); | ||
if (it == macros.end()) | ||
throw Exception("No macro " + macro_name + " in config", ErrorCodes::SYNTAX_ERROR); | ||
if (macro_name == "database") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly defined "database" and "table" macros should be preferred over implicit values.
@@ -207,7 +207,7 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree( | |||
: context(context_), | |||
database_name(database_name_), | |||
table_name(name_), full_path(path_ + escapeForFileName(table_name) + '/'), | |||
zookeeper_path(context.getMacros()->expand(zookeeper_path_)), | |||
zookeeper_path(context.getMacros()->expand(zookeeper_path_, 0, database_name, table_name)), | |||
replica_name(context.getMacros()->expand(replica_name_)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't allow database and table macros here?
@@ -207,7 +207,7 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree( | |||
: context(context_), | |||
database_name(database_name_), | |||
table_name(name_), full_path(path_ + escapeForFileName(table_name) + '/'), | |||
zookeeper_path(context.getMacros()->expand(zookeeper_path_)), | |||
zookeeper_path(context.getMacros()->expand(zookeeper_path_, 0, database_name, table_name)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should overload expand
method for convenience.
ddl_check_query(instance, "DROP TABLE IF EXISTS test_db.test_macro ON CLUSTER '{cluster}'") | ||
ddl_check_query(instance, "CREATE DATABASE IF NOT EXISTS test_db ON CLUSTER '{cluster}'") | ||
|
||
ddl_check_query(instance, """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't have a separate test?
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en