Merge pull request #63933 from jkartseva/allow-certain-alters-plain-rw

Allow certain ALTER TABLE commands for `plain_rewritable` disk
This commit is contained in:
Alexey Milovidov 2024-05-17 03:47:02 +00:00 committed by GitHub
commit 4021e9a507
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 56 additions and 3 deletions

View File

@ -3191,8 +3191,11 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, Context
"Experimental full-text index feature is not enabled (turn on setting 'allow_experimental_inverted_index')");
for (const auto & disk : getDisks())
if (!disk->supportsHardLinks())
throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "ALTER TABLE is not supported for immutable disk '{}'", disk->getName());
if (!disk->supportsHardLinks() && !commands.isSettingsAlter() && !commands.isCommentAlter())
throw Exception(
ErrorCodes::SUPPORT_IS_DISABLED,
"ALTER TABLE commands are not supported on immutable disk '{}', except for setting and comment alteration",
disk->getName());
/// Set of columns that shouldn't be altered.
NameSet columns_alter_type_forbidden;

View File

@ -80,6 +80,36 @@ def test_insert():
== insert_values_arr[i]
)
for i in range(NUM_WORKERS):
nodes[i].query("ALTER TABLE test MODIFY SETTING old_parts_lifetime = 59")
assert (
nodes[i]
.query(
"SELECT engine_full from system.tables WHERE database = currentDatabase() AND name = 'test'"
)
.find("old_parts_lifetime = 59")
!= -1
)
nodes[i].query("ALTER TABLE test RESET SETTING old_parts_lifetime")
assert (
nodes[i]
.query(
"SELECT engine_full from system.tables WHERE database = currentDatabase() AND name = 'test'"
)
.find("old_parts_lifetime")
== -1
)
nodes[i].query("ALTER TABLE test MODIFY COMMENT 'new description'")
assert (
nodes[i]
.query(
"SELECT comment from system.tables WHERE database = currentDatabase() AND name = 'test'"
)
.find("new description")
!= -1
)
@pytest.mark.order(1)
def test_restart():

View File

@ -9,6 +9,7 @@
4 4 4
4 7 7
5 5 5
1
10006
0 0 0
1 1 1
@ -20,3 +21,4 @@
4 4 4
4 7 7
5 5 5
0

View File

@ -9,8 +9,10 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
${CLICKHOUSE_CLIENT} --query "drop table if exists test_mt sync"
${CLICKHOUSE_CLIENT} -nm --query "
create table test_mt (a Int32, b Int64, c Int64) engine = MergeTree() partition by intDiv(a, 1000) order by tuple(a, b)
create table test_mt (a Int32, b Int64, c Int64)
engine = MergeTree() partition by intDiv(a, 1000) order by tuple(a, b)
settings disk = disk(
name = disk_s3_plain,
type = object_storage,
object_storage_type = local,
metadata_type = plain_rewritable,
@ -29,7 +31,23 @@ select (*) from test_mt order by tuple(a, b) limit 10;
${CLICKHOUSE_CLIENT} --query "optimize table test_mt final"
${CLICKHOUSE_CLIENT} -nm --query "
alter table test_mt modify setting disk = 'disk_s3_plain', old_parts_lifetime = 3600;
select engine_full from system.tables WHERE database = currentDatabase() AND name = 'test_mt';
" | grep -c "old_parts_lifetime = 3600"
${CLICKHOUSE_CLIENT} -nm --query "
select count(*) from test_mt;
select (*) from test_mt order by tuple(a, b) limit 10;
"
${CLICKHOUSE_CLIENT} -nm --query "
alter table test_mt update c = 0 where a % 2 = 1;
alter table test_mt add column d Int64 after c;
alter table test_mt drop column c;
" 2>&1 | grep -Fq "SUPPORT_IS_DISABLED"
${CLICKHOUSE_CLIENT} -nm --query "
truncate table test_mt;
select count(*) from test_mt;
"