Implement renameSchema for ClickHouse#10594
Implement renameSchema for ClickHouse#10594ebyhr merged 1 commit intotrinodb:masterfrom tangjiangling:support-alter-schema-rename-for-clickhouse
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 |
hashhar
left a comment
There was a problem hiding this comment.
Thanks for this. Looks good.
Couple of comments to make it more future proof.
- Let's try to do
renameSchemaunconditionally. - Instead of overriding
renameSchemawe can overriderenameSchemaSqlto return something like"RENAME DATABASE " + quoted(schemaName) + " TO " + quoted(newSchemaName). - Let's add a class called
TestClickhouseLatestConnectorSmokeTestand use a newer Clickhouse version there. SeeTestSqlServerLatestConnectorSmokeTestfor 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
TestClickhouseConnectorTestwhich creates a new database directly on Clickhouse with theATOMICengine 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. |
...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. |
hashhar
left a comment
There was a problem hiding this comment.
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? |
ebyhr
left a comment
There was a problem hiding this comment.
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