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 rename table without keyword TABLE #55373

Conversation

lingtaolf
Copy link
Contributor

Original issue : #55017

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Support rename table without keyword TABLE like RENAME db.t1 to db.t2

Documentation entry for user-facing changes

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

@lingtaolf lingtaolf force-pushed the enhancement/rename_without_keyword branch from 60fe7c5 to 8f82d64 Compare October 9, 2023 10:10
@ucasfl ucasfl added the can be tested Allows running workflows for external contributors label Oct 9, 2023
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-improvement Pull request with some product improvements label Oct 9, 2023
@robot-clickhouse-ci-1
Copy link
Contributor

robot-clickhouse-ci-1 commented Oct 9, 2023

This is an automated comment for commit e646fb7 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR✅ success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker image for serversThe check to build and optionally push the mentioned image to docker hub✅ success
Docs CheckBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integrational tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Mergeable CheckChecks if all other necessary checks are successful✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Push to DockerhubThe check for building and pushing the CI related docker images to docker hub✅ success
SQLTestThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool✅ success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style CheckRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success
Check nameDescriptionStatus
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure

@lingtaolf lingtaolf force-pushed the enhancement/rename_without_keyword branch from 413c190 to 2116377 Compare October 9, 2023 11:59
@antaljanosbenjamin antaljanosbenjamin self-assigned this Oct 9, 2023
@lingtaolf lingtaolf force-pushed the enhancement/rename_without_keyword branch 2 times, most recently from 408f570 to 6af3241 Compare October 10, 2023 02:54
@antaljanosbenjamin
Copy link
Member

So it seems it also renames dictionaries. I am not sure if that is good or not. Let me check.

@lingtaolf
Copy link
Contributor Author

lingtaolf commented Oct 10, 2023

So it seems it also renames dictionaries. I am not sure if that is good or not. Let me check.

I've tried rename dictionary with statement rename table dictionary_name to dictionary_name_2 on version 22.3.3.44 and I found this sql can be exeuted without exception. So It will not throw an exception when you rename dictionary using sql rename dictionary_name to dictionary_name_2 in this PR. Is that ok?

@lingtaolf
Copy link
Contributor Author

So it seems it also renames dictionaries. I am not sure if that is good or not. Let me check.

I've tried rename dictionary with statement rename table dictionary_name to dictionary_name_2 on version 22.3.3.44 and I found this sql can be exeuted without exception. So It will not throw an exception when you rename dictionary using sql rename dictionary_name to dictionary_name_2 in this PR. Is that ok?

Master branch can also rename dictionary via using RENAME TABLE statement.

Copy link
Member

@antaljanosbenjamin antaljanosbenjamin left a comment

Choose a reason for hiding this comment

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

Last request from me: could you please change the docs to mention that RENAME TABLE now should also work just as RENAME in docs/en/sql-reference/statements/rename.md? Don't forget to update the syntax of the RENAME command on the top of the page: instead of RENAME DATABASE|TABLE|DICTIONARY it should be RENAME [DATABASE|TABLE|DICTIONARY] I think.

@antaljanosbenjamin antaljanosbenjamin linked an issue Oct 10, 2023 that may be closed by this pull request
@lingtaolf lingtaolf force-pushed the enhancement/rename_without_keyword branch from 82948f2 to 51a5703 Compare October 11, 2023 06:12
@lingtaolf
Copy link
Contributor Author

The failed test does not appear to be related to this change, should I ignore them ?
@antaljanosbenjamin

docs/en/sql-reference/statements/rename.md Outdated Show resolved Hide resolved
Comment on lines 9 to 13
$CLICKHOUSE_CLIENT --param_db="$db_name" --multiquery \
--query="CREATE DATABASE {db:Identifier};
CREATE TABLE IF NOT EXISTS {db:Identifier}.r1 (name String) Engine=Memory();
SHOW TABLES FROM {db:Identifier}"
Copy link
Member

Choose a reason for hiding this comment

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

I think what @tavplubix was referring to (thanks for catching this!) is to use {CLICKHOUSE_DATABASE:Identifier} as a param for database name. It is appended by clickhouse-test (see here), so you don't need to manually generate anything.

Conveniently we also append CLICKHOUSE_DATABASE_1 identifier, so you can use that to rename the database to, so the last query can be written like

RENAME {CLICKHOUSE_DATABASE:Identifier} TO {CLICKHOUSE_DATABASE_1:Identifier}; -- { serverError UNKNOWN_TABLE }

As a result as we don't need anything generated, we can revert back the tests to the simpler sql file instead of running a shell script in my opinion.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it doesn't make sense for .sh tests because in .sh tests we have $CLICKHOUSE_DATABASE env var

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I undertand what you mean and I've update the test script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried use {CLICKHOUSE_DATABASE:Identifier}, but there were some strange problems. So I think using the current test script should also be ok.

Copy link
Member

Choose a reason for hiding this comment

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

I pushed the test using SQL files. Usually we prefer to use SQL files. The reasons I am aware of:

  1. They are simpler than the script based tests
  2. The queries in SQL scripts are picked up by the fuzzer and used to fuzz ClickHouse.

I hope you don't mind that I pushed a commit, but I think this make the tests better and it was easier for me. On the other hand, if you have any questions regarding to the test file, I am more than happy to answer it. If you want to understand why it wasn't working for you, I am also happy to help you, just show the errors you faced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx for your helping.

@lingtaolf lingtaolf force-pushed the enhancement/rename_without_keyword branch from 1192180 to 1886be8 Compare October 12, 2023 06:20
@lingtaolf lingtaolf force-pushed the enhancement/rename_without_keyword branch from 1886be8 to 4499dd3 Compare October 12, 2023 06:23
@lingtaolf lingtaolf force-pushed the enhancement/rename_without_keyword branch from 84fc959 to 89d123d Compare October 12, 2023 06:25
@antaljanosbenjamin
Copy link
Member

I think the failed test 00385_storage_file_and_clickhouse is not related, but let me make sure that we don't merge something that breaks master.

@antaljanosbenjamin
Copy link
Member

The failure might be connected to #55035

@antaljanosbenjamin antaljanosbenjamin merged commit eeff98f into ClickHouse:master Oct 16, 2023
285 of 286 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can be tested Allows running workflows for external contributors pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RENAME without TABLE keyword
5 participants