CLEAR COLUMN is silently skipped when combined with RENAME COLUMN of the same column in one ALTER statement
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with AlterCommands::prepare and splitAndModifyMutationCommands in src/Storages/MergeTree/MutateTask.cpp, then reproduce the combined RENAME COLUMN and CLEAR COLUMN statement with Wide and Compact parts. Compare the resulting data and mutation state; done means the renamed column is cleared consistently and the relevant regression test passes.
Written by the indexing model from the issue text.
Description
TL;DR: ALTER TABLE t RENAME COLUMN a TO c, CLEAR COLUMN c in a single statement reports success (mutations_sync = 2 returns, system.mutations.is_done = 1, no error), but the column data is not cleared: the old values survive under the new name. A user who relies on CLEAR COLUMN to destroy data (for example for privacy compliance) keeps the data on disk without any indication.
Describe what's wrong
When a RENAME COLUMN and a CLEAR COLUMN of the same column are combined in one ALTER statement, the CLEAR is silently skipped. On 25.8 this affects both Compact and Wide parts; on current master the Compact path clears correctly while the Wide path still keeps the old values, so the same statement gives different data depending on the part format.
The reverse order (CLEAR COLUMN a, RENAME COLUMN a TO c) is the already-reported #76485 (it fails with an exception). This report is about the rename-first order, which does not fail — it silently does nothing.
Does it reproduce on the most recent release?
Yes, reproduced on 25.8 (both part formats) and on master 26.9.1.1 (Wide parts).
How to reproduce
CREATE TABLE t (k Int32, a Int32) ENGINE = MergeTree ORDER BY k SETTINGS min_bytes_for_wide_part = 0;
INSERT INTO t VALUES (1, 7);
ALTER TABLE t RENAME COLUMN a TO c, CLEAR COLUMN c SETTINGS mutations_sync = 2;
SELECT c FROM t; -- returns 7, expected 0
https://fiddle.clickhouse.com/bbe4fa81-dbcc-4989-a84f-907e19882194 (25.8: both Wide and Compact return 7)
Controls:
- The same two commands as separate
ALTERstatements clear correctly (c = 0). - On master 26.9.1.1, the same statement on a Compact part clears correctly (
c = 0); a Wide part keepsc = 7. - Scale check on master, Wide part: after inserting 100000 rows with
sum(a) = 5009950000, the combined statement returns success andsum(c)is still 5009950000 (expected 0). The values surviveDETACH TABLE/ATTACH TABLE. CLEAR COLUMN IF EXISTS cafter the rename is skipped the same way.ReplicatedMergeTreebehaves the same (Wide part keeps the value, Compact part clears).
Expected behavior
The CLEAR COLUMN clears the renamed column: subsequent reads return the column type's default value, and the on-disk data of the old values is rewritten.
Additional context
system.mutations shows the mutation as done with an empty latest_fail_reason, so there is no signal that the clear did not happen. The open PR #117825 makes AlterCommands::prepare advance its working snapshot per command and reworks the same-batch rename handling in splitAndModifyMutationCommands (src/Storages/MergeTree/MutateTask.cpp); its new test expects this statement to clear, so it appears to fix the master Wide-part face, but released versions are affected today.
- Dominant language
- C++
- Stars
- 50k
- Forks
- 9k
- Avg merge
- 18h 29m
- Merged PRs (30d)
- 511
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/ClickHouse
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
comp-sql-syntax minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/ClickHouse#121170 ·
-
comp-sql-syntax
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121150 ·
-
comp-sql-syntax fuzz
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/ClickHouse#121027 · 2 comments ·
-
comp-sql-syntax fuzz
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ClickHouse/ClickHouse#121025 · 2 comments ·
All issues in ClickHouse/ClickHouse
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Sensor initialization takes very long when `--initial-sim-time` is set to current UNIX timestamp Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gazebosim/gz-sensors#662 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LadybirdBrowser/ladybird#12123 ·
-
[adam] AdamNet network read doesn't cap to MAX_ADAM_PACKET_LEN, overflows client receive buffers Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
FujiNetWIFI/fujinet-firmware#1649 · 2 comments ·