Repository navigation
Cover hive partition columns in the TopK query condition cache key of file - #127745
Conversation
… `file` The `file` table function creates its storage per query, and the per-query `use_hive_partitioning` decides whether a column such as `key` is read from the path or from the file. The TopK key covers the whole filter including conjuncts on hive partition columns, but neither the key nor the synthetic `table_id` covered the hive partition columns, so a query under one mode reused the TopK verdicts of the other and skipped row groups holding the result. Closes: #127721 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [56fe31f] Summary: ✅
AI ReviewSummaryThe PR prevents incorrect Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 22 s compile time in total, 7 of them have a recent master baseline. |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=127745&sha=latest&name_0=PR&name_1=Stateless%20tests%20(amd_debug%2C%20parallel) ( |
|
Confirmed: #127797 is the fix for both failures here. Both runs executed the test between 22:00 and 23:00 UTC with This hour repeats every day (again today at 22:00 UTC, report), so it keeps failing until #127797 is merged. Its CI has not started yet: it needs the |
alexey-milovidov
left a comment
There was a problem hiding this comment.
This is correct. However, I didn't like using the weak boost::hash_combine on top of SipHash-es.
|
@groeneai, after this is merged, make a follow-up PR according to my pedantic observation. |
|
Acknowledged. My open #127688 already builds this key with a single SipHash instead of the |
|
Done in #127688 (a7173b1): the hive partition columns go into the same single SipHash as the rest of the File TopK key, so the key has no While there, I found the same unprefixed name and type strings in the The MergeTree TopK salts still combine SipHash values with |
…o the File TopK SipHash Resolves the conflict with ClickHouse#127745, which added the hive partition columns to the File TopK query condition cache key as a fourth `boost::hash_combine` of a separate SipHash. They now go into the same single SipHash as the rest of the key (name and type name, each length-prefixed), so the key has no `boost::hash_combine` left. The file list is now followed by more variable-length fields in that one stream, so it is prefixed with its count to keep the encoding unambiguous. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…salt `tryAttachDynamicFilter` in `optimizeGroupByTopK.cpp` streamed the first ranked key and every grouping key as name and type name without their lengths, so `GROUP BY c` (`UInt8`) and `GROUP BY cU` (`Int8`) produced the same salt. With the `WHERE` kept as a separate filter, its query condition cache entry is keyed by the plain predicate and this salt only, so `GROUP BY c ORDER BY c DESC LIMIT 2` after the same query by `cU` reused the granules emptied by the `cU` boundary and returned `[1]` instead of `[200, 199]` (measured on master and on 26.10.2.103-stable with the cache and TopK settings at their defaults). Same fix as `topKPlanHash`; the test gets a `GROUP BY` arm. Found by the second-model review of the ClickHouse#127745 conflict resolution. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The
filetable function creates its storage per query, and the per-queryuse_hive_partitioningdecides whether a column such askeycomes from the path or from the file. The TopK query condition cache key ofReadFromFilecovers the whole filter, including conjuncts on hive partition columns. But neither that key nor the synthetictable_idfromQueryConditionCache::getTableIdForFileEntriescovered the hive partition columns. So the sameORDER BY ... LIMITquery under the other mode reused the cached TopK verdicts and skipped the row groups that hold the result: it returned[]instead of[999,998,997]in the reproducer from the issue.The fix hashes the names and types of the storage's hive partition columns into the TopK key. Plain-predicate entries are not affected, because
getFormatFilterstrips the hive conjuncts, so thetable_idstays the same and they are still shared. The regression was introduced by #122127 and is not in any release yet.Closes: #127721
Related: #122127
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127745]
Version info
26.11.1.905-master(included in26.11and later)