Repository navigation
Fix query condition cache hash collision for CTE folded constants - #96172
Merged
alexey-milovidov merged 2 commits intoFeb 7, 2026
Merged
Conversation
`ActionsDAG::Node::updateHash` did not hash actual constant values — only `column->getName()` which returns the type family name (e.g. `Const(Nullable(UInt16))`) regardless of the value. When constants are folded from CTE expressions, the `result_name` retains the expression-based name rather than the value, so two queries with different constant values but the same expression structure produced identical hashes, causing query condition cache collisions and incorrect results. Fix by also calling `column->updateHashWithValue` for `ColumnConst` nodes so the actual constant value is included in the hash. Closes #96060 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
|
Workflow [PR], commit [6010c57] Summary: ❌
|
…r `ColumnFunction` `ColumnFunction` previously threw `NOT_IMPLEMENTED` for all hash methods. When `ActionsDAG::Node::updateHash` calls `column->updateHashWithValue` on a `ColumnConst` wrapping a `ColumnFunction` (e.g. lambda expressions in prewhere), this caused an exception. Implement proper hashing by including the function name and delegating to the captured columns. Co-Authored-By: Claude Opus 4.6 <[email protected]>
alexey-milovidov
deleted the
fix-query-condition-cache-cte-constant-hash
branch
February 7, 2026 03:50
robot-clickhouse
added a commit
that referenced
this pull request
Feb 7, 2026
… CTE folded constants
robot-clickhouse
added a commit
that referenced
this pull request
Feb 7, 2026
… CTE folded constants
robot-clickhouse
added a commit
that referenced
this pull request
Feb 7, 2026
…r CTE folded constants
robot-clickhouse
added a commit
that referenced
this pull request
Feb 7, 2026
…r CTE folded constants
robot-clickhouse
added a commit
that referenced
this pull request
Feb 7, 2026
… CTE folded constants
clickhouse-gh Bot
added a commit
that referenced
this pull request
Feb 7, 2026
Backport #96172 to 26.1: Fix query condition cache hash collision for CTE folded constants
clickhouse-gh Bot
added a commit
that referenced
this pull request
Mar 29, 2026
Backport #96172 to 25.8: Fix query condition cache hash collision for CTE folded constants
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ActionsDAG::Node::updateHashdid not hash actual constant values — onlycolumn->getName()which returns the type family name (e.g.Const(Nullable(UInt16))) regardless of the value. When constants are folded from CTE expressions, theresult_nameretains the expression-based name rather than the value, so two queries with different constant values but the same expression structure produced identical hashes, causing query condition cache collisions and incorrect results.Fix by also calling
column->updateHashWithValueforColumnConstnodes so the actual constant value is included in the hash.Closes #96060
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix query condition cache hash collision for CTE folded constants, which could lead to a wrong query result. Closes #96060.
Version info
26.2.1.36426.1.3.22,25.8.22.5