Skip to content

Report a user error when a comment command follows MODIFY QUERY on a materialized view - #121469

Merged
PedroTadim merged 4 commits into
ClickHouse:masterfrom
groeneai:fix-alter-comment-column-after-modify-query
Sep 25, 2026
Merged

PedroTadim merged 4 commits into
ClickHouse:masterfrom
groeneai:fix-alter-comment-column-after-modify-query

Conversation

@groeneai

@groeneai groeneai commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed the logical error Cannot find column <name> in ColumnsDescription (a server abort in debug and sanitizer builds) raised when a single ALTER statement on a materialized view applies COMMENT COLUMN or MODIFY COLUMN ... COMMENT after a MODIFY QUERY whose new query no longer produces that column. Such a statement now reports the missing column.

Description

Found by CI: AST fuzzer (amd_debug, targeted), 2026-09-21. The defect is master's; #119469 only added the first in-tree statement combining these commands.

CREATE TABLE src (id UInt64) ENGINE = MergeTree ORDER BY id;
CREATE MATERIALIZED VIEW mv (id UInt64 COMMENT 'i') ENGINE = MergeTree ORDER BY id AS SELECT id FROM src;
ALTER TABLE mv (MODIFY QUERY SELECT id + 1 AS id2 FROM src), (COMMENT COLUMN id 'c');

Official 26.3.33.10, 26.6.5.73, 26.7.6.57 and 26.8.2.7 all raise Code: 49. Cannot find column id in ColumnsDescription. (LOGICAL_ERROR) there, and a debug or sanitizer build aborts.

Root cause. AlterCommands::apply applies commands in written order against one accumulating metadata. On a materialized view MODIFY QUERY replaces metadata.columns with the new query's output, so a later COMMENT_COLUMN / MODIFY_COLUMN reaches ColumnsDescription::modify() with a name that is gone, whose missing-column branch raises LOGICAL_ERROR. AlterCommands::validate screens these names, but models only ADD/DROP/MODIFY/RENAME COLUMN and never analyzes the SELECT, so it cannot see MODIFY QUERY rewriting a view's derived columns. The plain-table analogue is therefore clean.

Change. +16/-2. The runtime guard at those two branches covered only IF EXISTS; I complete it for the no-IF EXISTS case, reporting NOT_FOUND_COLUMN_IN_BLOCK with validate's wording and hints. The statistics branches beside it already guard columns.modify() this way. IF EXISTS is unchanged, and ColumnsDescription::modify keeps its LOGICAL_ERROR for other callers.

Siblings. RENAME COLUMN and DROP COLUMN are rejected earlier with NOT_IMPLEMENTED on a materialized view (measured), and MODIFY QUERY exists on no other storage, so these two are the whole reachable set.

Validation. New test 05237_alter_modify_query_comment_removed_column covers the defect, the sibling command, a TO-target view and two controls. Two servers from one tree: the unpatched aborts, the patched passes. 50/50 randomized and not; the 54 stateless tests naming these commands stay green.


Workflow [PR]
Sync PR [sync-upstream/pr/121469]

Version info

  • Merged into: 26.10.1.655-master (included in 26.10 and later)

…materialized view

AlterCommands::apply runs a statement's commands in written order against one
accumulating StorageInMemoryMetadata. On a materialized view, MODIFY QUERY replaces
metadata.columns wholesale with the new query's output columns. A COMMENT_COLUMN or
MODIFY_COLUMN command later in the same statement then called
ColumnsDescription::modify() with a name that is no longer present, and its
missing-column branch raises LOGICAL_ERROR ("Cannot find column id in
ColumnsDescription"). In a debug or sanitizer build abortOnFailedAssertion turns that
into a server abort; on a stable build the user gets Code 49 instead of a
missing-column error.

AlterCommands::validate already screens these names, but it models only
ADD/DROP/MODIFY/RENAME COLUMN effects on the column set: it never analyzes the SELECT,
so it cannot see MODIFY QUERY rewriting a view's derived columns. That is why the
plain-table analogue ((DROP COLUMN x), (COMMENT COLUMN x 'c')) is clean while the view
case aborted. The only existing runtime guard at these two branches was
should_skip_column_operation(), which covers the IF EXISTS case alone.

Complete that runtime check for the no-IF-EXISTS case at the two reachable branches and
report NOT_FOUND_COLUMN_IN_BLOCK, the error validate already produces for the same
commands, with its wording and its column-name hints. IF EXISTS behaviour is unchanged
(the if_exists arm is tested before the throw). The statistics branches in the same
function already guard columns.modify() this way with a user-facing error.

NOT_FOUND_COLUMN_IN_BLOCK is chosen over NO_SUCH_COLUMN_IN_TABLE so the view case is
indistinguishable from the plain-table case and the error class stops depending on which
storage the statement names. The reversed command order returns NO_SUCH_COLUMN_IN_TABLE
from checkTargetTableHasQueryOutputColumns, which is a different complaint about the new
output column, so making the two orders agree on one code is not the goal.

Carriers deliberately not changed: RENAME_COLUMN and DROP_COLUMN are rejected earlier
with NOT_IMPLEMENTED by StorageMaterializedView::checkAlterIsPossible (measured), and
MODIFY QUERY exists on no other storage, so neither is reachable with a stale column
name; ColumnsDescription::remove already throws a user-facing error in any case.
ColumnsDescription::modify keeps its LOGICAL_ERROR for every other caller, where a
missing column really is an internal invariant violation.

Found by the CI AST fuzzer on
https://github.com/ClickHouse/ClickHouse/actions/runs/35654611057/job/106546712698

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 22, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex): 2 gate findings plus 3 from my own
cold read, one fix round, then a delta re-review that returned 0 findings on the final tree.

# Sev Finding Verdict Evidence / action
1 ⚠️ New test lacks no-replicated-database and would be prohibited in the Replicated-database suite (tests/queries/0_stateless/05237_alter_modify_query_comment_removed_column.sql:1) AGREE, fixed InterpreterAlterQuery.cpp:282-297 rejects a statement mixing a replicated command with a comment alter, and MODIFY QUERY plus COMMENT COLUMN is exactly that shape. Same tag for the same shape: 04046_alter_modify_query_settings_formatting.sql:1. Tag added, then measured both ways: [ SKIPPED ] with it, [ FAIL ] ... got: 392 QUERY_IS_PROHIBITED without it, [ OK ] in the default flavor.
2 ⚠️ The kept-column control claimed the comment is applied, but it is discarded AGREE in part, fixed The claim was in a test comment only, and it was wrong: StorageMaterializedView.cpp:927-935 overwrites the altered columns with the target table's after apply. The comment now states what the arm verifies. The arm is not dead: clickhouse-test fails an unannotated query that errors, so an over-eager guard reds it.
3 ⚠️ Same finding, proposed remedy: assert system.columns.comment, or move the control to the TO-target view DISAGREE What a materialized view does with a column comment is the subject of open PR #119469, which this PR must not couple to. Asserting today's discard would break when that PR lands; asserting persistence would assume a behaviour this PR does not establish. This PR's contract is the error class only.
4 💡 MODIFY COLUMN message says "Wrong column name." while validate's own says "Wrong column." (AlterCommands.cpp:2236) DROPPED (mine) Upstream is already inconsistent: DROP (:2384), COMMENT (:2396) and RENAME (:2441) all say "Wrong column name."; only MODIFY differs. One shape for both actions is deliberate, and no test asserts either string on this path.
5 💡 No explicit MODIFY COLUMN IF EXISTS arm after MODIFY QUERY DROPPED (mine) That branch is already covered live by 03595_alter_if_exists_runtime_check.sql Test 2, which reaches the same guard with the column absent and IF EXISTS set. An arm for a covered branch is volume without coverage.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

The src/ change drew no blocker and no major in either round, and the fix round touched the test
file only (src/ and the .reference are byte-identical across it). I confirmed independently that
ColumnsDescription::has is the same lookup ColumnsDescription::modify performs before throwing,
so the only behavioural change is the error identity: every statement the new guard rejects already
failed on master. The chosen code matches what the tree already expects for this user mistake on a
plain table (03595_alter_drop_column_comment_if_exists.sql asserts NOT_FOUND_COLUMN_IN_BLOCK for
DROP COLUMN c0, COMMENT COLUMN c0), and no test in the tree asserts the old LOGICAL_ERROR.

Session id: cron:clickhouse-review-slot-10:20260922-011100

@clickhouse-gh clickhouse-gh Bot closed this Sep 22, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 22, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, 100%: the 3-statement script in the description, no randomization or timing involved.
b Root cause explained? Yes: MODIFY QUERY replaces a view's metadata.columns, so a later comment command reaches ColumnsDescription::modify() with a removed name; validate cannot model that because it never analyzes the SELECT.
c Fix matches root cause? Yes: the guard sits on the command that needs it, in the function that owns the authoritative column set, and reports the error validate reports for the same command. No widened bound, no tag, no masking of an upstream bug.
d Test intent preserved / new tests added? New test 05237_alter_modify_query_comment_removed_column, one case per scenario: defect, sibling command, IF EXISTS control, unchanged-column-set control, TO-target view, column-set oracle. No existing test weakened.
e Both directions demonstrated? Yes, twice. Per statement under clickhouse local: rc 134 Logical error: 'Cannot find column id in ColumnsDescription' before, Code: 10 NOT_FOUND_COLUMN_IN_BLOCK after. At test-file level on two servers built from the same tree: the unpatched server aborts running the test, the patched one reports [ OK ]. Build IDs verified against readelf, buildId() and the server log.
f Fix is general across code paths? Yes, every carrier of a statement-supplied column name in AlterCommand::apply was enumerated and measured. COMMENT_COLUMN and MODIFY_COLUMN fixed; RENAME COLUMN and DROP COLUMN are rejected earlier with NOT_IMPLEMENTED on a materialized view, and MODIFY QUERY exists on no other storage; the statistics branches already guard columns.modify() with a user-facing error.
g Fix generalizes across inputs? The guard is a name lookup, so type wrappers do not participate. Varied and measured anyway: inner-table and TO-target views, COMMENT COLUMN and MODIFY COLUMN ... COMMENT, 1-column and 2-column views (the latter also exercises the name hints), a MODIFY QUERY that keeps the column and one that drops it, with and without IF EXISTS.
h Backward compatible? Yes. A statement that raised Code: 49 now raises Code: 10; every affected statement already fails today, so nothing that works today changes. No setting, default, format or on-disk metadata touched, so no SettingsChangesHistory.cpp entry is owed.
i Invariants and contracts preserved? Invariant: a command keyed by a statement-supplied column name either finds the column, is a documented IF EXISTS no-op, or reports a user-facing missing-column error, never LOGICAL_ERROR. The throw is the only added exit and it happens before any mutation of the metadata, so a rejected command leaves the accumulating metadata untouched (asserted by the test's column-set oracle). IF EXISTS early-return order is preserved, and ColumnsDescription::modify keeps its LOGICAL_ERROR for every other caller.

Session id: cron:clickhouse-impl-slot-5:20260921-234800

@clickhouse-gh

clickhouse-gh Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fdc62db]

Summary: ❌

job_name test_name status info comment
Upgrade check (amd_release) FAIL
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb IGNORED
Performance Comparison (arm_release, master_head, 6/6) FAIL Performance dashboard
bitmap_cardinality #1 FAIL dashboard IGNORED

AI Review

Summary

This PR fixes the removed-column half of a materialized-view ALTER: when MODIFY QUERY drops a column and a later COMMENT COLUMN or MODIFY COLUMN ... COMMENT in the same statement still targets that name, AlterCommand::apply now reports the user-facing NOT_FOUND_COLUMN_IN_BLOCK error instead of bubbling the internal LOGICAL_ERROR from ColumnsDescription::modify. That targeted fix looks correct, but the mixed MODIFY QUERY + comment-alter surface is still only half-fixed because the added-column case remains blocked earlier in AlterCommands::validate / AlterCommands::prepare.

Findings

⚠️ Majors

  • [dismissed by author -- https://github.com/Report a user error when a comment command follows MODIFY QUERY on a materialized view #121469#discussion_r4070364474] src/Storages/AlterCommands.cpp:2094-2099, 2230-2240, 2389-2398; src/Storages/StorageMaterializedView.cpp:921-935: A later COMMENT COLUMN / MODIFY COLUMN ... COMMENT that targets a column introduced by the same MODIFY QUERY still cannot work on a TO materialized view. StorageMaterializedView::alter would apply the new query first and then comment the new column, but AlterCommands::validate never advances all_columns across MODIFY QUERY, and AlterCommands::prepare still marks the IF EXISTS form ignore against the pre-alter schema. So ALTER TABLE mv (MODIFY QUERY SELECT id, id + 1 AS id2 FROM src), (COMMENT COLUMN id2 'c') still throws or silently skips the comment even though the end state is already achievable via two separate ALTERs. Suggested fix: teach AlterCommands::validate and AlterCommands::prepare to switch to the post-MODIFY QUERY column set for later comment alters, or reject that mixed statement explicitly as unsupported.
Final Verdict

⚠️ The removed-column fix itself is sound, but one unresolved major remains on the same MODIFY QUERY + comment-alter surface and is already tracked in the open thread above.

@clickhouse-gh

clickhouse-gh Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing fdc62db9a with master 0f47f73a4 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 15 s compile time in total, 7 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 073dbc9

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt, and it is green here.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, 1/8) / test_max_bytes_ratio_before_external_distinct[server] Code: 241 at test.py:134, i.e. the spilling arm the test expects to succeed: (total) memory limit exceeded: would use 2.65 GiB (attempt to allocate chunk of 64.50 MiB), current RSS: 3.97 GiB, maximum: 4.00 GiB ... While executing BufferingFromFileSource. The 4 GiB node is new (merged #121096) and this signature has never been seen before 2026-09-21 18:26Z; since then it is 54 rows over 49 unrelated PRs with 5 true-master reds #121454 (external, open)
Performance Comparison (arm_release, master_head, 1/6) / order_by_read_in_order #1 Shard summary is 5 too long, 1 slower; 1 confirmed regression(s) on the performance dashboard, and this job never obtained its learned thresholds: Select historical data failed three times with Read timed out. (read timeout=10) at 04:25Z, so the slower verdict is the 0.15/0.25 floor rather than a per-query bar. The same query is called slower on 76 true-master rows and 40 other PRs in 14 days, and nothing in this diff reaches an ORDER BY read-in-order path #121189 + #121090 (mine, open; they close this case only as a pair)
Performance Comparison (arm_release, master_head, 3/6) / set_index #0 Same shard summary and the same lost threshold fetch (three read timeout=10 failures at 04:25Z). set_index #0 is called slower on 13 true-master rows in 14 days, and this diff only rejects a comment command that follows MODIFY QUERY #121189 + #121090 (mine, open; they close this case only as a pair)
Mergeable Check, PR Aggregate rollups with no independent failure: Failed: 3 #121454, #121189, #121090, as the three rows above

Session id: cron:our-pr-ci-monitor:20260922-063421

@PedroTadim PedroTadim self-assigned this Sep 22, 2026
return if_exists && !metadata.columns.has(column_name);
};

/// validate() screens these column names too, but against a model that tracks only ADD/DROP/MODIFY/RENAME

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only fixes the "column disappeared" half of the MODIFY QUERY mismatch. validate() still never advances all_columns for MODIFY QUERY, so a later comment on a column introduced by the new query is rejected before we ever reach this helper, and the IF EXISTS form is still silently dropped in prepare().

Concrete path on a TO view:

CREATE TABLE dst (id UInt64, id2 Nullable(UInt64)) ENGINE = MergeTree ORDER BY id;
CREATE MATERIALIZED VIEW mv TO dst AS SELECT id FROM src;
ALTER TABLE mv
    (MODIFY QUERY SELECT id, id + 1 AS id2 FROM src),
    (COMMENT COLUMN id2 'c');

StorageMaterializedView::checkAlterIsPossible() already allows that command mix, and params.apply() would have new_metadata.columns = {id, id2} by the time it reaches the comment alter. But AlterCommands::validate() still throws from the COMMENT_COLUMN / MODIFY_COLUMN checks because its working snapshot is stuck on the pre-alter schema, and COMMENT COLUMN IF EXISTS id2 then gets marked ignore in prepare() for the same reason. Can we teach validate()/prepare() the post-MODIFY QUERY column set for later comment alters (or explicitly reject that mixed statement as unsupported)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified, both halves are real, and both are pre-existing. I ran the same arms on two binaries under clickhouse local: the master debug snapshot 26.10.1.1, which contains no code from this PR, and this PR's head b09555b1 (build id 7b8b3de8a000c444).

# Arm master snapshot this PR
1 TO view, (MODIFY QUERY SELECT id, id + 1 AS id2 FROM src), (COMMENT COLUMN id2 'c') Code: 10 ... Cannot find column 'id2' to comment. Maybe you meant: ['id'] identical
2 arm 1 with COMMENT COLUMN IF EXISTS id2 'c' succeeds, id2's comment stays empty identical
3 arm 1's two commands as two separate ALTERs both succeed, comment c persists on id2 identical
4 arm 1 on an inner-table view same Code: 10 identical
5 (MODIFY QUERY ...), (MODIFY COLUMN id2 COMMENT 'c') Code: 10 ... to modify identical
6 the removed-column case this PR is about abort, exit 134 Code: 10

Arm 6 is the only row that differs, and that is structural: the diff sits entirely in AlterCommand::apply, whereas InterpreterAlterQuery calls validate() at :374 and prepare() at :380 before table->alter() at :382, and AlterCommands::apply skips ignored commands at :1832. Arm 1 throws inside validate(); in arm 2 the command is already marked ignore. The helper you commented on is unreachable in both.

One correction on the IF EXISTS half: it is not specific to MODIFY QUERY. prepare() computes has_column once per command from the unadvanced pre-alter snapshot (:1974), so any preceding command has the same effect. Same binary, plain MergeTree table:

  • ALTER TABLE t (ADD COLUMN y UInt8), (COMMENT COLUMN IF EXISTS y 'c') succeeds with y's comment empty.
  • (ADD COLUMN y UInt8), (MODIFY COLUMN IF EXISTS y COMMENT 'c') behaves the same.

Without IF EXISTS that pair works, because validate() does advance all_columns for ADD COLUMN (:2226). That asymmetry is the gap, not MODIFY QUERY alone, and closing it also changes behaviour for existing ADD COLUMN pairs.

So I am keeping this PR at the removed-column fix and tracking the added-column case separately. It is worth fixing: arm 3 shows the end state arm 1 asks for is legitimate, so arm 1 rejects a request that is already expressible, and its hint points at the wrong column. Of your two options I would not take "reject the mixed statement as unsupported" unless a maintainer asks for it, since it has to reject arm 2, which succeeds today. I will post the fix PR link here when it opens.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added-column half turns out to depend on this PR, so I would rather not open it standalone.

The fix is to stop screening a column name once a MODIFY QUERY earlier in the same statement has replaced the set, in validate() and in prepare(), and let the sequential AlterCommands::apply decide. That is about 12 lines. It only works on top of skip_absent_column_or_fail: with those two screens relaxed, a genuine typo such as (MODIFY QUERY SELECT id FROM src), (COMMENT COLUMN typo 'c') reaches ColumnsDescription::modify and produces arm 6's exit 134 instead of a user error. So this PR is the prerequisite, and I am not going to duplicate its diff into a second one.

One correction to my previous message: closing the IF EXISTS gap does not have to change behaviour for ADD COLUMN pairs. Latching only on MODIFY QUERY in prepare() leaves (ADD COLUMN y UInt8), (COMMENT COLUMN IF EXISTS y 'c') exactly as it is today.

Do you want those 12 lines and their test pushed here, or as a follow-up PR once this merges? I will default to the follow-up if you would rather not grow this one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please push it here. It is the remaining half of the same mixed MODIFY QUERY + comment-alter surface, and since it depends on this helper it is cleaner to land it in the same PR than as a follow-up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have those 12 lines ready: stop screening the column name in validate() and in prepare() once a MODIFY QUERY earlier in the same statement has replaced the column set, and let the sequential AlterCommands::apply own the check. The prepare() half is what closes the IF EXISTS case, and the latch is on MODIFY QUERY alone, so (ADD COLUMN y UInt8), (COMMENT COLUMN IF EXISTS y 'c') keeps the behaviour it has today.

They only work on top of this PR. Master still does not carry skip_absent_column_or_fail (checked at 1be97a74), so with those two screens relaxed a plain typo such as (MODIFY QUERY SELECT id FROM src), (COMMENT COLUMN typo 'c') reaches ColumnsDescription::modify and gives an internal error that aborts a debug build, instead of Code: 10.

What I do not want to do is grow this PR on my own initiative. Two reviewers are requested on it, a master merge landed on the branch at 00:31 UTC and its CI is still in flight, and the diff here is a single guard in AlterCommand::apply, which is cheap to review as it stands.

@Michicosun you are one of the requested reviewers and have the recent history on this file, so I would rather have your call: those 12 lines plus their test pushed here, or a follow-up PR once this merges? I will default to the follow-up and post its link in this thread.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai go with a follow-up PR. For this one, change the category for bugfix.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done on both.

Category: switched to Bug Fix (user-visible misbehavior in an official stable release) and re-voiced the changelog entry to match. I measured it first, since the repro had been filed as an improvement: it raises Code: 49. Cannot find column id in ColumnsDescription. (LOGICAL_ERROR) on official 26.3.33.10, 26.6.5.73, 26.7.6.57 and 26.8.2.7, and aborts a debug build, so it is a stable-release defect present in every one of those releases.

Follow-up: the validate()/prepare() half stays out of this PR and goes in its own. I will post the link in this thread when it opens.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up is open: #122213

It is the validate()/prepare() half, on top of this one now that it has merged: both screens stop at a MODIFY QUERY earlier in the same statement, so a comment command can name a column the new query introduces, and AlterCommand::apply keeps the rejection for a genuinely absent name. Filed as Improvement, since the pairing was never a supported spelling, so no release misbehaves on it.

@clickhouse-gh clickhouse-gh Bot added the comp-ddl DDL command coordination and execution (ON CLUSTER, DDL queue). label Sep 22, 2026
/// COLUMN - not MODIFY QUERY, which replaces a materialized view's columns with its new query's output.
auto skip_absent_column_or_fail = [&](std::string_view action) -> bool
{
if (metadata.columns.has(column_name))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai could you call should_skip_column_operation here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in fdc62db: the guard now calls should_skip_column_operation() for the skip decision and only decides between "the column is present, proceed" and "report the user error", so the if_exists predicate lives in one place.

Behaviour is unchanged, since the two predicates are mutually exclusive. Verified on a debug build: 05237_alter_modify_query_comment_removed_column passes 10/10, a missing column without IF EXISTS still reports NOT_FOUND_COLUMN_IN_BLOCK, with IF EXISTS the comment is still skipped and the statement fails on the inner table with NO_SUCH_COLUMN_IN_TABLE, and the control where the new query keeps the column still succeeds.

Review request: the new absent-column guard spelled the IF EXISTS test out a
second time, so the two copies of that predicate could drift. It now calls
should_skip_column_operation(), which already owns it, and decides only
between "the column is present, proceed" and "report the user error".

Behaviour is unchanged. should_skip_column_operation() is
if_exists && !metadata.columns.has(column_name), so the three outcomes stay
the same and stay mutually exclusive: a missing column under IF EXISTS skips
the command, a present column proceeds, and a missing column without
IF EXISTS reports NOT_FOUND_COLUMN_IN_BLOCK with the column-name hints.
@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-improvement Pull request with some product improvements labels Sep 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - fdc62db

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Error message in clickhouse-server.log a mutation retry logs Code: 47 UNKNOWN_IDENTIFIER for b ("Maybe you meant: ['a']") from MutatePlainMergeTreeTask; 43 rows across 41 PRs in 14 days, 0 true-master #118499 (mine, open)
Performance Comparison (arm_release, master_head, 6/6) / bitmap_cardinality #1 perf gate, not a measurement of this diff. The shard's own report says 3 too long, 1 unstable with zero slower; the red is the dashboard tier confirmed_regression (+30.0%, 0.337 -> 0.438 s). bitmap_cardinality #1::new is unstable on 30 PRs and 5 true-master rows in 7 days. Measured at the tree that ran (1b5fb1b0a9f2, job 107738468118): #121847 IS present and the shard failed anyway, and its threshold-fetch arm did not fire here (0 read timeouts, thresholds present and consumed), so #121847 is not the owner ClickHouse/performance-comparison#5 (external, the dashboard confidence-scoring half, named by @ fm4v as the owner of this class)

Mergeable Check and PR are commit-status rollups of the two rows above, not independent failures.
CH Inc sync measured success at this head (14:38:44Z).

Nothing is PR-caused: the diff is +16/-2 in src/Storages/AlterCommands.cpp plus one stateless test,
which reaches neither a mutation retry on a stale part nor a bitmap aggregate benchmark.

Session id: cron:our-pr-ci-monitor:20260924-183043

@PedroTadim
PedroTadim added this pull request to the merge queue Sep 25, 2026
Merged via the queue into ClickHouse:master with commit 711f560 Sep 25, 2026
335 of 341 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-ddl DDL command coordination and execution (ON CLUSTER, DDL queue). groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants