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

Support {database} and {table} macros in ReplicatedMergeTree [CLICKHOUSE-3897] #3251

Merged
merged 7 commits into from
Oct 1, 2018
Merged

Conversation

CurtizJ
Copy link
Member

@CurtizJ CurtizJ commented Sep 28, 2018

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

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

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

Missing update of comment.

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")
Copy link
Member

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_)),
Copy link
Member

@alexey-milovidov alexey-milovidov Sep 30, 2018

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)),
Copy link
Member

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, """
Copy link
Member

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?

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.

2 participants