mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Merge pull request #44159 from ClickHouse/prevent-delete-nested-if-empty-part
Prevent dropping nested column if it creates empty part
This commit is contained in:
commit
3593377f23
@ -2600,7 +2600,17 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, Context
|
||||
}
|
||||
}
|
||||
|
||||
dropped_columns.emplace(command.column_name);
|
||||
if (old_metadata.columns.has(command.column_name))
|
||||
{
|
||||
dropped_columns.emplace(command.column_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto & nested = old_metadata.columns.getNested(command.column_name);
|
||||
for (const auto & nested_column : nested)
|
||||
dropped_columns.emplace(nested_column.name);
|
||||
}
|
||||
|
||||
}
|
||||
else if (command.type == AlterCommand::RESET_SETTING)
|
||||
{
|
||||
|
@ -0,0 +1,49 @@
|
||||
DROP TABLE IF EXISTS 02500_nested;
|
||||
|
||||
SET flatten_nested = 1;
|
||||
|
||||
CREATE TABLE 02500_nested(arr Array(Tuple(a Int32, b Int32))) Engine=MergeTree ORDER BY tuple();
|
||||
INSERT INTO 02500_nested(arr.a, arr.b) VALUES ([1], [2]);
|
||||
ALTER TABLE 02500_nested ADD COLUMN z Int32;
|
||||
ALTER TABLE 02500_nested DROP COLUMN arr; -- { serverError BAD_ARGUMENTS }
|
||||
DROP TABLE 02500_nested;
|
||||
|
||||
CREATE TABLE 02500_nested(arr Array(Tuple(a Int32, b Int32)), z Int32) Engine=MergeTree ORDER BY tuple();
|
||||
INSERT INTO 02500_nested(arr.a, arr.b, z) VALUES ([1], [2], 2);
|
||||
ALTER TABLE 02500_nested DROP COLUMN arr;
|
||||
DROP TABLE 02500_nested;
|
||||
|
||||
CREATE TABLE 02500_nested(nes Nested(a Int32, b Int32)) Engine=MergeTree ORDER BY tuple();
|
||||
INSERT INTO 02500_nested(nes.a, nes.b) VALUES ([1], [2]);
|
||||
ALTER TABLE 02500_nested ADD COLUMN z Int32;
|
||||
ALTER TABLE 02500_nested DROP COLUMN nes; -- { serverError BAD_ARGUMENTS }
|
||||
DROP TABLE 02500_nested;
|
||||
|
||||
CREATE TABLE 02500_nested(nes Array(Tuple(a Int32, b Int32)), z Int32) Engine=MergeTree ORDER BY tuple();
|
||||
INSERT INTO 02500_nested(nes.a, nes.b, z) VALUES ([1], [2], 2);
|
||||
ALTER TABLE 02500_nested DROP COLUMN nes;
|
||||
DROP TABLE 02500_nested;
|
||||
|
||||
SET flatten_nested = 0;
|
||||
|
||||
CREATE TABLE 02500_nested(arr Array(Tuple(a Int32, b Int32))) Engine=MergeTree ORDER BY tuple();
|
||||
INSERT INTO 02500_nested(arr) VALUES ([(1, 2)]);
|
||||
ALTER TABLE 02500_nested ADD COLUMN z Int32;
|
||||
ALTER TABLE 02500_nested DROP COLUMN arr; -- { serverError BAD_ARGUMENTS }
|
||||
DROP TABLE 02500_nested;
|
||||
|
||||
CREATE TABLE 02500_nested(arr Array(Tuple(a Int32, b Int32)), z Int32) Engine=MergeTree ORDER BY tuple();
|
||||
INSERT INTO 02500_nested(arr, z) VALUES ([(1, 2)], 2);
|
||||
ALTER TABLE 02500_nested DROP COLUMN arr;
|
||||
DROP TABLE 02500_nested;
|
||||
|
||||
CREATE TABLE 02500_nested(nes Nested(a Int32, b Int32)) Engine=MergeTree ORDER BY tuple();
|
||||
INSERT INTO 02500_nested(nes) VALUES ([(1, 2)]);
|
||||
ALTER TABLE 02500_nested ADD COLUMN z Int32;
|
||||
ALTER TABLE 02500_nested DROP COLUMN nes; -- { serverError BAD_ARGUMENTS }
|
||||
DROP TABLE 02500_nested;
|
||||
|
||||
CREATE TABLE 02500_nested(nes Array(Tuple(a Int32, b Int32)), z Int32) Engine=MergeTree ORDER BY tuple();
|
||||
INSERT INTO 02500_nested(nes, z) VALUES ([(1, 2)], 2);
|
||||
ALTER TABLE 02500_nested DROP COLUMN nes;
|
||||
DROP TABLE 02500_nested;
|
Loading…
Reference in New Issue
Block a user