-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Implement renameSchema for ClickHouse #10594
Implement renameSchema for ClickHouse #10594
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
cc @hashhar |
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.
Thanks for this. Looks good.
Couple of comments to make it more future proof.
- Let's try to do
renameSchema
unconditionally. - Instead of overriding
renameSchema
we can overriderenameSchemaSql
to return something like"RENAME DATABASE " + quoted(schemaName) + " TO " + quoted(newSchemaName)
. - Let's add a class called
TestClickhouseLatestConnectorSmokeTest
and use a newer Clickhouse version there. SeeTestSqlServerLatestConnectorSmokeTest
for example. This will allow us to test that rename schema works out of box when used with newer clickhouse versions. - Let's add one more test method to
TestClickhouseConnectorTest
which creates a new database directly on Clickhouse with theATOMIC
engine and verify that rename schema works for it. That way we can also test that rename schema works with older versions of Clickhouse too if the database engine is ATOMIC.
The reasoning for this is that we already do this for some other methods in some connectors. And it's possible that our assumptions today will become false in future if there are more changes in Clickhouse. The only additional thing we should do is to make sure that the error message received when renaming a non-ATOMIC database is still useful/actionable for the user. |
.../trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseDatabaseEngineType.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
.../trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseDatabaseEngineType.java
Outdated
Show resolved
Hide resolved
@tangjiangling Could you rebase on upstream to resolve conflicts? |
Okay, I will update the current PR as soon as possible. |
Updated, still some TOODs that can be seen in the code. |
This requires us to support ClickHouse database properties for Is this in our follow-up planning? If it is, I'd like to do it. |
@tangjiangling Regarding the new test you can use |
Okay, I'll take a look. |
The full error message is as above, which I think is sufficient for the user. |
Updated. |
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.
Could you add below two lines to docs/src/main/sphinx/connector/clickhouse.rst
?
* :doc:`/sql/alter-schema`
at L192.. include:: alter-schema-limitation.fragment
at L194
...n/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java
Outdated
Show resolved
Hide resolved
...no-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorSmokeTest.java
Outdated
Show resolved
Hide resolved
...ckhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java
Outdated
Show resolved
Hide resolved
Already added and verified in local build. |
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.
Squash all the commits. Features and tests should be in same commit. It makes bisecting failures in future a lot easier (and also ensures that a later commit doesn't fix something in a previous commit - i.e. all commits build and pass tests)
Thanks for working on this.
Good suggestion. @hashhar One more question: does the commit about document also need to be merged into the same commit? |
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.
Looks good except for one question.
does the commit about document also need to be merged into the same commit?
Yes in this case :)
When you modify unrelated docs in a PR, it should be separated commits.
...no-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java
Outdated
Show resolved
Hide resolved
...no-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java
Outdated
Show resolved
Hide resolved
The current implementation executes `ALTER SCHEMA ... RENAME` unconditionally, and let ClickHouse throw the proper errors. The reasoning for this is that we already do this for some other methods in some connectors. And it's possible that our assumptions today will become false in future if there are more changes in ClickHouse.
Merged, thanks! |
Fixes: #10558
The current implementation checks if it is an ATOMICdatabase in ClickHouseClient when RENAME SCHEMA