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

Copy comment when using CREATE AS statement #62117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3d7c1db
Copy comment when using CREATE AS statement
pamarcos Mar 31, 2024
8b1fcf3
Use CLICKHOUSE_DATABASE in SQL test
pamarcos Apr 2, 2024
73e5620
Relax check-style condition because in SQL-based tests there's no $
pamarcos Apr 2, 2024
4a65a06
Revert "Relax check-style condition because in SQL-based tests there'…
pamarcos Apr 2, 2024
836169a
Use currentDatabase() instead of CLICKHOUSE_DATABASE
pamarcos Apr 2, 2024
6d43118
Only copy comment if it's not empty
pamarcos Apr 2, 2024
e1041da
Update reference for 02904_distributed_settings_background_insert_com…
pamarcos Apr 2, 2024
1910e92
Add missing newline at end of reference file
pamarcos Apr 2, 2024
f49c151
Fix build for PostgreSQL, MySQL and SQLite
pamarcos Apr 2, 2024
b6c059c
Fix build for HDFS and S3
pamarcos Apr 2, 2024
8bdcac4
Force a new build
pamarcos Apr 2, 2024
e785327
Merge branch 'master' into pamarcos/copy_comment_in_create_as_statement
pamarcos Apr 3, 2024
6b3e92f
Merge branch 'master' into pamarcos/copy_comment_in_create_as_statement
pamarcos Apr 5, 2024
c427092
Merge branch 'master' into pamarcos/copy_comment_in_create_as_statement
pamarcos Apr 7, 2024
04f819a
Merge branch 'master' into pamarcos/copy_comment_in_create_as_statement
pamarcos Apr 8, 2024
e3a0abd
Merge branch 'master' into pamarcos/copy_comment_in_create_as_statement
pamarcos Apr 14, 2024
9d87cec
Don't use ASTPtr for the comment following feedback in the PR
pamarcos Apr 14, 2024
2a65b00
Merge branch 'master' into pamarcos/copy_comment_in_create_as_statement
pamarcos Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Interpreters/InterpreterCreateQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,9 @@ InterpreterCreateQuery::TableProperties InterpreterCreateQuery::getTableProperti
auto as_storage_metadata = as_storage->getInMemoryMetadataPtr();
properties.columns = as_storage_metadata->getColumns();

if (!create.comment && !as_storage_metadata->comment.empty())
create.set(create.comment, std::make_shared<ASTLiteral>(as_storage_metadata->comment));

/// Secondary indices and projections make sense only for MergeTree family of storage engines.
/// We should not copy them for other storages.
if (create.storage && endsWith(create.storage->engine->name, "MergeTree"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CREATE TABLE default.dist_monitor_batch_inserts\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS monitor_batch_inserts = 1
CREATE TABLE default.dist_monitor_split_batch_on_failure\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS monitor_split_batch_on_failure = 1
CREATE TABLE default.dist_monitor_sleep_time_ms\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS monitor_sleep_time_ms = 1
CREATE TABLE default.dist_monitor_max_sleep_time_ms\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS monitor_max_sleep_time_ms = 1
CREATE TABLE default.dist_background_insert_batch\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS background_insert_batch = 1
CREATE TABLE default.dist_background_insert_split_batch_on_failure\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS background_insert_split_batch_on_failure = 1
CREATE TABLE default.dist_background_insert_sleep_time_ms\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS background_insert_sleep_time_ms = 1
CREATE TABLE default.dist_background_insert_max_sleep_time_ms\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS background_insert_max_sleep_time_ms = 1
CREATE TABLE default.dist_monitor_batch_inserts\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS monitor_batch_inserts = 1\nCOMMENT \'This table contains a single row with a single dummy UInt8 column containing the value 0. Used when the table is not specified explicitly, for example in queries like `SELECT 1`.\'
CREATE TABLE default.dist_monitor_split_batch_on_failure\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS monitor_split_batch_on_failure = 1\nCOMMENT \'This table contains a single row with a single dummy UInt8 column containing the value 0. Used when the table is not specified explicitly, for example in queries like `SELECT 1`.\'
CREATE TABLE default.dist_monitor_sleep_time_ms\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS monitor_sleep_time_ms = 1\nCOMMENT \'This table contains a single row with a single dummy UInt8 column containing the value 0. Used when the table is not specified explicitly, for example in queries like `SELECT 1`.\'
CREATE TABLE default.dist_monitor_max_sleep_time_ms\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS monitor_max_sleep_time_ms = 1\nCOMMENT \'This table contains a single row with a single dummy UInt8 column containing the value 0. Used when the table is not specified explicitly, for example in queries like `SELECT 1`.\'
CREATE TABLE default.dist_background_insert_batch\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS background_insert_batch = 1\nCOMMENT \'This table contains a single row with a single dummy UInt8 column containing the value 0. Used when the table is not specified explicitly, for example in queries like `SELECT 1`.\'
CREATE TABLE default.dist_background_insert_split_batch_on_failure\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS background_insert_split_batch_on_failure = 1\nCOMMENT \'This table contains a single row with a single dummy UInt8 column containing the value 0. Used when the table is not specified explicitly, for example in queries like `SELECT 1`.\'
CREATE TABLE default.dist_background_insert_sleep_time_ms\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS background_insert_sleep_time_ms = 1\nCOMMENT \'This table contains a single row with a single dummy UInt8 column containing the value 0. Used when the table is not specified explicitly, for example in queries like `SELECT 1`.\'
CREATE TABLE default.dist_background_insert_max_sleep_time_ms\n(\n `dummy` UInt8\n)\nENGINE = Distributed(\'test_shard_localhost\', \'system\', \'one\')\nSETTINGS background_insert_max_sleep_time_ms = 1\nCOMMENT \'This table contains a single row with a single dummy UInt8 column containing the value 0. Used when the table is not specified explicitly, for example in queries like `SELECT 1`.\'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
original comment
original comment
new comment
11 changes: 11 additions & 0 deletions tests/queries/0_stateless/03033_create_as_copies_comment.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DROP TABLE IF EXISTS base;
DROP TABLE IF EXISTS copy_without_comment;
DROP TABLE IF EXISTS copy_with_comment;

CREATE TABLE base (a Int32) ENGINE = TinyLog COMMENT 'original comment';
CREATE TABLE copy_without_comment AS base;
CREATE TABLE copy_with_comment AS base COMMENT 'new comment';

SELECT comment FROM system.tables WHERE database = currentDatabase() AND name = 'base';
SELECT comment FROM system.tables WHERE database = currentDatabase() AND name = 'copy_without_comment';
SELECT comment FROM system.tables WHERE database = currentDatabase() AND name = 'copy_with_comment';