Repository navigation
Parquet: count only selected columns in read_bytes - #105413
PedroTadim merged 7 commits into
Conversation
`Parquet::ReadManager::read` reported the entire row group's `total_compressed_size` as the bytes-read approximation for each chunk, i.e. summing every column in the file rather than only the columns the query actually reads. For a query selecting K of N columns this overcounted `read_bytes` (and the derived bytes/s in `system.query_log`, progress bar, etc.) by a factor of `N / K`. For Iceberg tables with many columns and many files it surfaced as absurd TB/s readings. Sum per-column compressed sizes for the columns in `reader.primitive_columns` instead. `PrimitiveColumnInfo::column_idx` indexes into `row_group.meta->columns`, so we pick exactly the column chunks the query touches. Also wire `IcebergIterator::next` through the `IDataLakeMetadata::FileProgressCallback`: the iterator already stores the callback but never invoked it, so file-level `total_bytes_to_read` was zero for Iceberg scans. The generic `KeysIterator` in `IDataLakeMetadata.cpp` already calls the callback the same way. Adds `04260_parquet_read_bytes_selected_columns.sh`, which writes a 10-column Parquet file, reads one column vs. all ten, and asserts the one-column scan reports at most one fifth of the bytes the ten-column scan reports. Before the fix both queries reported the same row-group total (~7 MB) and the assertion failed. Closes ClickHouse#105333 Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Pre-PR validation gate (per worker policy):
Test: |
|
cc @al13n321 @Michicosun @alesapin - could you review? Two-line fix in |
|
Workflow [PR], commit [eb9fe57] Summary: ❌
AI ReviewSummaryThis PR fixes Parquet V3 Final VerdictStatus: ✅ Approve |
|
@groeneai many tests are failing, check |
The fix in ReadManager.cpp now correctly counts only the compressed sizes of columns the query actually reads. The reference file still held the pre-fix inflated bytes_read values, so the test failed deterministically across 4 stateless test variants (amd_debug, amd_llvm_coverage, amd_tsan, arm_binary). Only bytes_read numbers change. rows_read, data, and rows are unchanged. Verified locally: 60/60 passes with --test-runs 30 randomization.
|
Pushed The same fix in Pre-PR validation gate: a) Deterministic repro: yes. CI showed 12/12, 15/15, 3/3, 1/1 reruns failing. Local reproduction was 5/5 identical on b) Root cause: the c) Fix matches root cause: updating the reference values is the only correct action. The fix in d) Test intent preserved: yes. The test verifies bloom-filter pushdown effectiveness via e) Both directions demonstrated: with the OLD reference + NEW binary the test fails with the same diff CI reported. With the NEW reference + NEW binary the test passes. Verified f) Fix is general: this is a test reference adjustment, not a code change. The general fix is the one already in the PR. Session: |
…ogical values The reference update in commit 5801513 captured `uint64_logical: 7711695863945021976` (the exact 64-bit integer) because the local `jq` (1.7+, Ubuntu 24.04) preserves big integers literally. CI's `jq` is 1.6, which routes JSON numbers through `double`, rounding the value to `7711695863945022000`. The test was passing on master with the rounded value before this PR rebased the reference. Revert just the two `uint64_logical` lines (lines 510, 523) back to the CI-emitted rounded value. All `bytes_read` values from the previous commit are correct on both environments and are kept. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105413&sha=5801513ae6ec03f8b98f471e9e6bacf675892dfd&name_0=PR PR: ClickHouse#105413
|
Pushed Root causeThe reference update in
I regenerated the entire The Pre-PR validation gatea) Deterministic repro? Yes. CI's b) Root cause explained? Yes (see above). c) Fix matches root cause? Yes. Revert exactly the two d) Test intent preserved? Yes. The two affected queries verify bloom-filter pushdown DOES NOT prune row groups when there is a e) Both directions demonstrated? Yes.
f) General fix? Scope-bounded. There is a latent jq-version dependence in the test (introduced when the test was created on 2026-05-20, before this PR). It only manifests for developers running locally with CI report (failing commit): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105413&sha=5801513ae6ec03f8b98f471e9e6bacf675892dfd&name_0=PR Session: cron:clickhouse-ci-task-worker:20260521-023000 |
Covers the `IcebergIterator::next` file-progress callback wiring introduced in this PR. Scans a small Iceberg table over the native TCP protocol (the path where `TCPHandler::setFileProgressCallback` is wired) and asserts that `system.query_log` has a non-zero `IcebergMetadataReturnedObjectInfos` ProfileEvent for the query. The ProfileEvent is incremented immediately before the new `callback(FileProgress(...))` call in `IcebergIterator::next`, so it is the closest persistent observable for the callback path: `Progress.total_bytes_to_read` itself is not retained in `system.query_log`, and the regular HTTP progress callback chain does not consume `FileProgressCallback` (only `TCPHandler` and `LocalConnection` install that callback on the query context). Uses `SELECT *` with `FORMAT Null` rather than `SELECT count()` because the Iceberg metadata-only count path resolves the row count from manifest statistics without iterating the data-file iterator, so `count()` does not exercise `IcebergIterator::next`. Closes the inline review request from clickhouse-gh[bot] and @PedroTadim on ClickHouse#105413 for focused coverage of the Iceberg progress-reporting fix. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
@PedroTadim done in 39d0f49. New test: The test scans a small Iceberg table over the native TCP protocol and asserts that I picked the ProfileEvent rather than
If you would prefer that I also extend Verified locally:
|
The Iceberg integration test introduced for PR ClickHouse#105413 asserted ProfileEvents['IcebergMetadataReturnedObjectInfos'] > 0, but that counter is incremented one line BEFORE the callback(FileProgress(...)) call in IcebergIterator::next. Removing only the callback line would still pass the test, so the assertion did not actually validate the callback wiring it was meant to protect. This commit: - Adds FileProgressCallbackInvocations to ProfileEvents. - Increments it inside the lambda installed by TCPHandler::setFileProgressCallback and LocalConnection::setFileProgressCallback, so the counter is bumped exactly when the per-file callback fires. - Updates test_iceberg_file_progress_callback to assert ProfileEvents['FileProgressCallbackInvocations'] > 0 instead of the adjacent IcebergMetadataReturnedObjectInfos. For an Iceberg-table scan, IcebergIterator replaces the generic StorageObjectStorageSource::KeysIterator path, so during such a scan IcebergIterator::next is the only caller that can invoke FileProgressCallback. A non-zero value of the new ProfileEvent for this query proves the callback line in IcebergIterator::next ran. Locally verified: with the callback line present the test passes (invocations = 1); with the callback line commented out the test fails (invocations = 0). Addresses the inline review by clickhouse-gh[bot] (seconded by @PedroTadim) on tests/integration/test_database_iceberg/test.py in PR ClickHouse#105413.
|
@PedroTadim @clickhouse-gh[bot] thanks for the precise critique. You are right, the previous assertion sat one line away from the callback and would have passed even if the The cleanest observable I could find for the callback path is a new ProfileEvent, For an Iceberg-table scan Verified locally in both directions on
Background on why I went for a new ProfileEvent rather than reading Diff vs the previous PR head is 4 files / 65 lines:
CI is re-running on |
Pre-PR validation gate (a-f) for commit
|
| Scenario | FileProgressCallbackInvocations |
Test result |
|---|---|---|
Current PR state (if (callback) callback(FileProgress(...));) |
1 |
PASSED (22.14s) |
| Callback call site removed (simulated regression) | 0 |
FAILED with the expected assertion message |
Re-built the binary in each case and re-ran the test via python3 -m ci.praktika run "integration" --test "test_database_iceberg/test.py::test_iceberg_file_progress_callback".
f) Fix is general, not a narrow patch? Yes. The ProfileEvent is incremented in the callback wiring sites for both TCPHandler and LocalConnection, the two places where setFileProgressCallback is currently wired. Other handlers (HTTP, gRPC) do not currently wire setFileProgressCallback at all, so the counter is correctly absent there. The new event also gives any future caller of setFileProgressCallback an observable signal for tests and for operational debugging, beyond just the Iceberg use case in this PR.
…-parquet-bytes-selected-columns
|
Merged master into the branch at 93bb50f to refresh CI. The branch was 509 commits behind master, and the For the record, the 20 |
|
@groeneai do one more merge with master |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 29/30 (96.67%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 4 line(s) · Uncovered code |
5af715f
Parquet::ReadManager::readreported the entire row group'stotal_compressed_sizeas the bytes-read approximation for each chunk, i.e. summing every column in the file rather than only the columns the query actually reads. For a query selecting K of N columns this overcountedread_bytes(and the derived bytes/s insystem.query_log, progress bar, etc.) by a factor ofN / K. For Iceberg tables with many columns and many files it surfaced as TB/s readings when actual I/O was orders of magnitude smaller.The fix sums per-column compressed sizes for the columns in
reader.primitive_columns.PrimitiveColumnInfo::column_idxindexes intorow_group.meta->columns, so we pick exactly the column chunks the query touches.Also wires
IcebergIterator::nextthroughIDataLakeMetadata::FileProgressCallback: the iterator already stored the callback but never invoked it, so file-leveltotal_bytes_to_readwas zero for Iceberg scans. The genericKeysIteratorinIDataLakeMetadata.cppalready calls the callback the same way.Regression test
04260_parquet_read_bytes_selected_columns.shwrites a 10-column Parquet file, reads one column vs. all ten, and asserts the one-column scan reports at most one fifth of the bytes the ten-column scan reports. Before the fix both queries reported the same row-group total (~7 MB) and the assertion failed.Closes #105333
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix inflated
read_bytes(and the derived bytes/s shown insystem.query_log, progress bar, etc.) when reading Parquet files. The previous implementation reported the row group's total compressed size on every chunk, so reading K of N columns overcounted byN / K. It is now summed only across the selected columns. Also fixes file-level progress tracking for Iceberg tables, which previously never reported the data file size.Version info
26.6.1.385