mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-20 05:05:38 +00:00
consider the case of alter table add projection
This commit is contained in:
parent
36c57ca50b
commit
09619e6006
@ -3211,6 +3211,16 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, Context
|
||||
queryToString(mutation_commands.ast()));
|
||||
}
|
||||
|
||||
/// Block the case of alter table add projection for special merge trees.
|
||||
if (std::any_of(commands.begin(), commands.end(), [](const AlterCommand & c) { return c.type == AlterCommand::ADD_PROJECTION; }))
|
||||
{
|
||||
if (auto storage_name = getName(); storage_name != "MergeTree" && storage_name != "ReplicatedMergeTree"
|
||||
&& settings_from_storage->deduplicate_merge_projection_mode == DeduplicateMergeProjectionMode::THROW)
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED,
|
||||
"Projection is fully supported in (Replictaed)MergeTree, but also allowed in non-throw mode with other"
|
||||
" mergetree family members. Consider drop or rebuild option of deduplicate_merge_projection_mode.");
|
||||
}
|
||||
|
||||
commands.apply(new_metadata, local_context);
|
||||
|
||||
if (AlterCommands::hasFullTextIndex(new_metadata) && !settings.allow_experimental_full_text_index)
|
||||
|
@ -0,0 +1 @@
|
||||
p
|
@ -59,8 +59,7 @@ OPTIMIZE TABLE tp FINAL;
|
||||
-- expecting no projection
|
||||
SYSTEM FLUSH LOGS;
|
||||
SELECT
|
||||
name,
|
||||
part_name
|
||||
name
|
||||
FROM system.projection_parts
|
||||
WHERE (database = currentDatabase()) AND (`table` = 'tp') AND (active = 1);
|
||||
|
||||
@ -81,4 +80,27 @@ ALTER TABLE tp MODIFY SETTING deduplicate_merge_projection_mode = 'throw';
|
||||
|
||||
OPTIMIZE TABLE tp DEDUPLICATE; -- { serverError NOT_IMPLEMENTED }
|
||||
|
||||
DROP TABLE tp;
|
||||
|
||||
-- test alter add projection case
|
||||
CREATE TABLE tp (
|
||||
type Int32,
|
||||
eventcnt UInt64
|
||||
) engine = ReplacingMergeTree order by type;
|
||||
|
||||
ALTER TABLE tp ADD PROJECTION p (SELECT sum(eventcnt), type GROUP BY type); -- { serverError NOT_IMPLEMENTED }
|
||||
|
||||
ALTER TABLE tp MODIFY SETTING deduplicate_merge_projection_mode = 'drop';
|
||||
|
||||
ALTER TABLE tp ADD PROJECTION p (SELECT sum(eventcnt), type GROUP BY type);
|
||||
|
||||
INSERT INTO tp SELECT number%3, 1 FROM numbers(3);
|
||||
|
||||
SYSTEM FLUSH LOGS;
|
||||
-- expecting projection p
|
||||
SELECT
|
||||
name
|
||||
FROM system.projection_parts
|
||||
WHERE (database = currentDatabase()) AND (`table` = 'tp') AND (active = 1);
|
||||
|
||||
DROP TABLE tp;
|
Loading…
Reference in New Issue
Block a user