Repository navigation
25.8 stable: Fix for Aliases and Lazy Materialization - #2560
Conversation
|
Repro CREATE TABLE t_str (id UInt64, ts DateTime, s String, s_alias String ALIAS s) The issue is introduced by ClickHouse#55518 and fixed by ClickHouse#90309 , 25.8 remained not covered. The change is not a backport, it is a very small fix. |
Signed-off-by: Ilya Golshtein <igolshtein@altinity.com>
6f0a6cb to
e47d7e8
Compare
Signed-off-by: Ilya Golshtein <igolshtein@altinity.com>
|
PR to upstream ClickHouse#126104 |
There was a problem hiding this comment.
LGTM.
In later versions code was fully refactored in ClickHouse#90309, so fix is required only in 25.8 and older.
CI triage — 1 real failure, not caused by this PRVerdict: The only genuine failure is Stress test (amd_ubsan). It is a pre-existing / flaky stress-test crash in the backup-RESTORE path, unrelated to this PR's change. ( Why it's not this PRThis PR only changes the lazy-materialization query-plan optimizer and its test:
The crash is in a completely different subsystem — The failure
Stack: Evidence it's pre-existing, not PR-induced
Suggested next step
Head SHA analyzed: 🤖 Generated with Claude Code |
PR #2560 Audit Review
VerdictOne Low finding. No High or Medium. The reported logical error is fixed on the default plan. Selecting a column and its alias under The Low finding is the same check applied one step too early when What the change does
The new check, in /// The lazy reader maps each source column to a single output name. If an input
/// is forwarded more than once (for example, both a column and its alias), read
/// it eagerly so all outputs contain real data and do not duplicate lazy row coordinates.
if (node->type == ActionsDAG::ActionType::INPUT && !passthrough_inputs.insert(node->result_name).second)
{
const auto it = alias_index.find(node->result_name);
if (it != alias_index.end())
lazily_read_column_name_set.erase(it->second);
}
The stateless test is Why the crash happens
An alias of a
Why the fix holds on the default plan
A function, FindingsDuplicate passthroughLow: with expression merging off, computing a table ALIAS column disables lazy materialization of its source.
What was checked and found cleanThe reported query under default settings. Both names unwrap to one A single alias, whether a table
Mutations with patch parts, Coverage
Deferred: none. No Operational readinessPersona: anyone running Primary flow: The default flow is ready. Both selected names come back as real values. The alias alone is still lazy-read. The only guardrail is for the Low finding: leave Recommended fix: move the duplicate check from each intermediate expression onto the sorting output header, and extend |
|
Bugfix strictly for 25.8 and older versions. No PR-caused CI fails. AI audit returned only low defects. LGTM |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Logical Error fixed if both Alias and original column are selected.
Documentation entry for user-facing changes
...
CI/CD Options
Exclude tests:
Regression jobs to run: