Repository navigation
Add mergeTreeCodecBlockCounts table function - #109623
Conversation
|
Workflow [PR], commit [5d4f278] Summary: ✅
AI ReviewSummaryThis PR adds the Findings
Final Verdict |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
Michicosun
left a comment
There was a problem hiding this comment.
Why isn't it implemented as a part of system.parts_columns?
|
@Michicosun multiple reasons. First of all, Second reason is row policies. When user tries to access |
rienath
left a comment
There was a problem hiding this comment.
Thanks for the comment. I committed WHERE pushdown on key columns and row policy protection as discussed. On top, mergeTreeCodecBlockCounts now displays codecs of patch parts.
|
@groeneai merge master into this PR, failing test was fixed |
|
I cannot push to block-walk: it lives in ClickHouse/ClickHouse rather than my fork, and as an external contributor my push returns 403 (Permission denied). So I am unable to merge master in for you. You can do it yourself with the "Update branch" button on this PR, or on the branch: |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 191/196 (97.45%) · Uncovered code |
…curately The worked example said "Neither path had a test". That is wrong: #109623 shipped ten `.sql` files for the function, and both paths the paragraph names are exercised. `04267_mergeTreeCodecBlockCounts_basic.sql` hits the non-`MergeTree` `BAD_ARGUMENTS` on the structure path, and `04509_mergeTreeCodecBlockCounts_row_policy.sql` asserts `ACCESS_DENIED` at read time. The narrowing suggested in review — that only a regression test for the unprivileged `DESCRIBE` was missing — is not the whole gap either. No `mergeTreeCodecBlockCounts` test creates a user or grants anything, and none issues a `DESCRIBE`, so every one of them runs as the privileged current user. The `checkAccess(AccessType::SELECT, …)` in `read` therefore had no test on any path: `04509` exercises the row-policy branch that sits beside it in `read`, which is a different guard, reached from `getRowPolicyFilter` rather than from the grant check. So the accurate statement is stronger than either version and is the rule's own point: the suite covered the code paths but never once ran without the grant, so nothing in it distinguished a check on one entrypoint from a check on all of them. The gap was "no negative case", not "no tests" — which is why the rule asks for one negative case per guarded entrypoint rather than for path coverage.
`mergeTreeCodecBlockCounts` (ClickHouse#109623) checked `SELECT` on its source table in `StorageMergeTreeCodecBlockCounts::read` only. The review looked straight at that check and argued its column granularity was too coarse; the author answered that the strict check was intentional, and the review ended there. Meanwhile `getActualTableStructure` went straight to `DatabaseCatalog`, so `DESCRIBE mergeTreeCodecBlockCounts(db, t)` succeeded for a user with no privilege on `db.t`, and the `BAD_ARGUMENTS` thrown for a table of another engine disclosed that engine. Fixed by ClickHouse#116647. The miss was not a failure to read the right file. It was answering the shape question about a guard instead of the prior question of whether every path reaches it, and having no inventory of what the entrypoints of a table function are. - New triggered expansion for an access check or a new surface derived from another object, pointing at `references.md#access-checks`. - New `references.md` section with the procedure: completeness before granularity, the entrypoint inventory (`getActualTableStructure`, reached by `DESCRIBE` and `CREATE TABLE ... AS`, `executeImpl`, `read`, `totalRows`/`totalBytes`, inherited mutating operations), the note that `getActualTableStructureWithAccess` covers only source access and never `SELECT` on a table named in the arguments, why metadata and error text are protected information, one negative test per entrypoint, the sibling sweep, and severity. - New general rule "Do not let one finding close a topic": a finding about a mechanism is not a review of it, and an author's "this is intentional" closes the shape question only. - Blocker for a check any entrypoint can bypass, including one that exposes only structure, metadata, or an error message naming a property of the object. - Test-coverage rule: a new access check needs a negative test per guarded entrypoint; no test at all is a Major, since nothing then distinguishes a check on every path from a check on one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Add `mergeTreeCodecBlockCounts` table function
It returns one row per (active part, column, substream) with a map counting the substream's compressed blocks by codec, plus the substream's compressed and uncompressed sizes.
system.columnsreports a single codec taken from metadata, while the codec that actually compressed each block is recorded only in the block's own header. Seeing the difference is useful already, e.g.ALTER TABLE ... MODIFY COLUMN ... CODECchanges only metadata, and existing parts keep the old codec until something rewrites them. It's a must with adaptive codec selection (RFC: #105404), which picks codecs per block. This PR implements the RFC's observability part.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added the
mergeTreeCodecBlockCounts(database, table)table function that reports, per (part, column, substream) of aMergeTreetable, how many compressed blocks use each codec.Version info
26.8.1.36(included in26.8and later)