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

Fix lightweight delete after drop of projection #52517

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/Storages/MergeTree/MergeTreeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5693,6 +5693,10 @@ bool MergeTreeData::supportsLightweightDelete() const
auto lock = lockParts();
for (const auto & part : data_parts_by_info)
{
if (part->getState() == MergeTreeDataPartState::Outdated
|| part->getState() == MergeTreeDataPartState::Deleting)
continue;

if (!part->supportLightweightDeleteMutate())
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
99
20 changes: 20 additions & 0 deletions tests/queries/0_stateless/02792_drop_projection_lwd.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SET mutations_sync = 2;

DROP TABLE IF EXISTS t_projections_lwd;

CREATE TABLE t_projections_lwd (a UInt32, b UInt32, PROJECTION p (SELECT * ORDER BY b)) ENGINE = MergeTree ORDER BY a;

INSERT INTO t_projections_lwd SELECT number, number FROM numbers(100);

-- LWD does not work, as expected
DELETE FROM t_projections_lwd WHERE a = 1; -- { serverError BAD_ARGUMENTS }
KILL MUTATION WHERE database = currentDatabase() AND table = 't_projections_lwd' SYNC FORMAT Null;

-- drop projection
ALTER TABLE t_projections_lwd DROP projection p;

DELETE FROM t_projections_lwd WHERE a = 2;

SELECT count() FROM t_projections_lwd;

DROP TABLE t_projections_lwd;