mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 03:22:14 +00:00
Allow certain ALTER TABLE commands for plain_rewritable
Currently all alters are disallowed, this is too restrictive. Allow altering settings (through {MODIFY|RESET} SETTING) and comments (MODIFY COMMENT).
This commit is contained in:
parent
6b6f8334c5
commit
81a7862ed4
@ -3013,8 +3013,11 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, Context
|
|||||||
"Experimental full-text index feature is not enabled (turn on setting 'allow_experimental_inverted_index')");
|
"Experimental full-text index feature is not enabled (turn on setting 'allow_experimental_inverted_index')");
|
||||||
|
|
||||||
for (const auto & disk : getDisks())
|
for (const auto & disk : getDisks())
|
||||||
if (!disk->supportsHardLinks())
|
if (!disk->supportsHardLinks() && !commands.isSettingsAlter() && !commands.isCommentAlter())
|
||||||
throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "ALTER TABLE is not supported for immutable disk '{}'", disk->getName());
|
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.
|
/// Set of columns that shouldn't be altered.
|
||||||
NameSet columns_alter_type_forbidden;
|
NameSet columns_alter_type_forbidden;
|
||||||
|
@ -80,6 +80,36 @@ def test_insert():
|
|||||||
== insert_values_arr[i]
|
== 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)
|
@pytest.mark.order(1)
|
||||||
def test_restart():
|
def test_restart():
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
4 4 4
|
4 4 4
|
||||||
4 7 7
|
4 7 7
|
||||||
5 5 5
|
5 5 5
|
||||||
|
1
|
||||||
10006
|
10006
|
||||||
0 0 0
|
0 0 0
|
||||||
1 1 1
|
1 1 1
|
||||||
@ -20,3 +21,4 @@
|
|||||||
4 4 4
|
4 4 4
|
||||||
4 7 7
|
4 7 7
|
||||||
5 5 5
|
5 5 5
|
||||||
|
0
|
||||||
|
@ -9,8 +9,10 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
${CLICKHOUSE_CLIENT} --query "drop table if exists test_mt sync"
|
${CLICKHOUSE_CLIENT} --query "drop table if exists test_mt sync"
|
||||||
|
|
||||||
${CLICKHOUSE_CLIENT} -nm --query "
|
${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(
|
settings disk = disk(
|
||||||
|
name = disk_s3_plain,
|
||||||
type = object_storage,
|
type = object_storage,
|
||||||
object_storage_type = local,
|
object_storage_type = local,
|
||||||
metadata_type = plain_rewritable,
|
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} --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 "
|
${CLICKHOUSE_CLIENT} -nm --query "
|
||||||
select count(*) from test_mt;
|
select count(*) from test_mt;
|
||||||
select (*) from test_mt order by tuple(a, b) limit 10;
|
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;
|
||||||
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user