-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Add parameterized RENAME queries #46407
Add parameterized RENAME queries #46407
Conversation
Just as a suggestion since you are working on parameterized queries anyways right now, https://github.com/ClickHouse/product/issues/800 is similar but for CREATE USERS. Perhaps it is easy to add parameterization support for these queries as well? |
SET param_old_tbl_name = 02661_t; | ||
SET param_new_tbl_name = 02661_t1; | ||
|
||
CREATE TABLE {new_db_name:Identifier}.{old_tbl_name:Identifier} (a UInt64) ENGINE = MergeTree ORDER BY tuple(); |
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.
Maybe we should also support something like
SET param_table_name = qualified.name;
CREATE TABLE {table_name:Identifier} (a UInt64) ...
(it should create a table named name
in a database named qualified
)
Because qualified.name
is a valid compound identifier.
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.
I'm not sure about how it will behave in the case when the table name contains a dot, for example `table.first` in current implementation will become default.`table.first`, and first.`table` if we change it.
Maybe we should implement special parameter type CompoundIdentifier for this?
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.
Yes, makes sense
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.
Another option is to use ParserCompoundIdentifier
to parse a value passed to an Identifier parameter but seems like it may be backward incompatible
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.
Ok, will do it in a separate PR
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.
Another option is to use ParserCompoundIdentifier to parse a value passed to an Identifier parameter but seems like it may be backward incompatible
Yeah, and it seems like it will only create confusion on the user's part, so a separate type for it looks like the best solution
Already working on it, it will be implemented as a part of this PR: #44674 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Allow writing RENAME queries with query parameters. Resolves #45778