Repository navigation
Conversation
A count-only read (`optimize_count_from_files`) takes the row count of each file from its metadata and gets one chunk per file whose columns are constant placeholders. `StorageObjectStorageSource::generate` converted every constant column of every chunk to a full column, so such a `count()` allocated and filled one value per row of the file in one thread (about 800 MB for a 100M-row Parquet object). The conversion was added by ClickHouse#95773 because INSERT squashing merged the DeltaLake partition constants of different files into one value (ClickHouse#95526). ClickHouse#97019 fixed that in `Squashing::squash`, which materializes `ColumnConst` before concatenation, so the conversion in the source is no longer needed. With ClickHouse#97019's materialization disabled, a DeltaLake `INSERT ... SELECT` hits the `ColumnConst::insertRangeFrom` assertion; with it, the values are right. A single chunk that squashing passes through is materialized by the INSERT pre-sink (`addMissingDefaults` wraps every output column in `materialize`), and SELECT output by `QueryPipeline::complete`, so format sinks and `Buffer` still receive full columns. The new test pins `optimize_trivial_count_query`: with it off, `count()` requests a column and reads the file instead of taking the count-only path. Reported in ClickHouse#132859. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 findings in round 1, 0 in round 2) plus my own review (4 findings).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261119-061200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261119-054900 |
|
Workflow [PR], commit [09fc2d0] Summary: ❌
AI ReviewSummaryReviewed PR #132892 at Because data reads can now expose constant DeltaLake partition columns, the consumer review covered:
Missing context / blind spots
Final Verdict✅ Approve. No new inline findings to post. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1408 translation units recompiled, 49 s compile time in total, 1408 of them have a recent master baseline. |
CI finish ledger - 09fc2d0Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Every amd_release Performance Comparison shard passed, including the new Session id: cron:our-pr-ci-monitor:20261119-100025 |
|
The four
@egor-click, this reopens the gate question from #131211 (comment): should the perf job downgrade a confirmed slowdown when the functions the query spends its time in have identical machine code in both binaries (I can send that PR), or should such rows stay blocking for the reviewer to judge? |
|
i feel like that is better for the reviewer to judge |
|
Understood, so I will not send the gate PR. No fixing PR will follow for the two |
Related: #132859
Related: #95773
Related: #97019
Related: #124174
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
count()and other reads that only need the number of rows (for examplesum(1)) overs3,azureBlobStorage,hdfsand data lake tables no longer allocate a column with one value per row of each file. Such acount()over a 100M-row Parquet object now uses about 1 MB of memory instead of about 800 MB.Description
With
optimize_count_from_files, a count-only read takes the row count of each file from its metadata and gets one chunk per file whose columns are constant placeholders.StorageObjectStorageSource::generateconverted every constant column of every chunk to a full column (#95773), so that chunk was expanded to all rows of the file.#95773 added the conversion because INSERT squashing merged the DeltaLake partition constants of different files into one value (#95526). #97019 fixed that in
Squashing::squash, which now materializes constants before concatenation, so this PR removes the conversion. A single chunk that squashing passes through unchanged is materialized by the INSERT pre-sink (addMissingDefaultswraps every output column inmaterialize), so inserting from a partitioned DeltaLake table intofile(CSV, TSV, JSONEachRow),s3(CSV) andBufferwrites the same rows as on master.Semantic edge: in a data read, DeltaLake partition columns are constant per chunk again (
isConstantreturns 1), as before #95773. Virtual, hive and Iceberg identity-partition columns and the Iceberg and Paimon schema-evolution defaults were already full and are unchanged. The object-storage condition of #124174 targets the removed block and drops out on rebase.Validation (debug build, local MinIO):
count()over a 100M-rowStringobject 801 MB / 108 ms -> 0.9 MB / 11 ms; asum(x)data read is unchanged. The new stateless test fails on master withMEMORY_LIMIT_EXCEEDED(76.7 MiB under a 40 MiB limit) and passes 50/50 with random settings. Thetest_storage_deltapartition-column tests,03918_insert_squashing_const_different_values, and Iceberg (position deletes), hive,s3Clusterandmerge()reads return the same results as master. The analysis and the release-build measurements are from #132859.Workflow [PR]
Sync PR [sync-upstream/pr/132892]