Skip to content

Fix iceberg object info clone and optimize count - #122861

Open
ianton-ru wants to merge 6 commits into
ClickHouse:masterfrom
ianton-ru:fix-iceberg-object-info-clone
Open

ianton-ru wants to merge 6 commits into
ClickHouse:masterfrom
ianton-ru:fix-iceberg-object-info-clone

Conversation

@ianton-ru

@ianton-ru ianton-ru commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

ObjectIteratorSplitByBuckets previously sliced IcebergDataObjectInfo to ObjectInfo, dropping equality and position deletes under BUCKET granularity.

The copy was std::make_shared<ObjectInfo>(*object), so the derived info was discarded. Cluster reads with cluster_table_function_buckets_batch_size could skip equality deletes, position deletes, and deletion vectors and return deleted rows. ObjectInfo::clone copies polymorphically. IcebergDataObjectInfo::clone keeps info (position deletes, the deletion vector, equality deletes, and partition columns), data_lake_metadata, and rows_to_read. ObjectInfoInArchive::clone keeps the archive reader, which the same slice would drop.

count() over deletion vectors and position deletes now stays on the Parquet need_only_count path: footer and row-group metadata, plus roaring range cardinality, instead of decoding data pages. Equality deletes still disable that path, because their predicates need real column values. The count-from-files cache stays fail-closed whenever deletes are attached. Bucketed need_only_count counts only the assigned row groups and does not write a partial total into the file-level cache.

This is the clone fix and the count() optimizations split out of #113561. Deletion-vector read support from that pull request landed separately in #110781.

Related: #113561
Related: #110781

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Preserve Iceberg delete metadata when splitting files into buckets, and count deletion-vector and position-delete tables from Parquet row-group metadata. Copying ObjectInfo by value dropped deletes, and a bucketed count() previously used the whole file and could cache that partial total.


Workflow [PR]
Sync PR [sync-upstream/pr/122861]

ianton-ru and others added 2 commits September 29, 2026 13:18
`ObjectIteratorSplitByBuckets` copied `ObjectInfo` by value, which dropped deletion vectors, position deletes, and equality deletes. `clone` keeps the derived object.

Co-authored-by: Cursor <[email protected]>
`need_only_count` stays on for deletion vectors and position deletes and uses roaring range cardinality, while equality deletes still read real column values. Bucketed counts use only the assigned row groups and do not poison the file-level count cache.

Co-authored-by: Cursor <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Sep 29, 2026
@ianton-ru ianton-ru changed the title Fix iceberg object info clone Fix iceberg object info clone and optimize count Sep 29, 2026
@ianton-ru
ianton-ru marked this pull request as ready for review September 29, 2026 16:26
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Sep 30, 2026
@tuanpach tuanpach added the can be tested Allows running workflows for external contributors label Oct 1, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0deefb0]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_binary, s3 storage, DBReplicated, sequential) FAIL
03254_prewarm_mark_cache_rmt FAIL cidb
Performance Comparison (arm_release, master_head, 3/6) FAIL Performance dashboard
parquet_wide_footer #0 FAIL dashboard

AI Review

Summary

The PR preserves derived object metadata across bucket splits and enables Parquet metadata counts with bitmap deletes. Two issues remain: ordinary empty-column chunks can lose physical row mappings, and newly enabled count paths can materialize an entire row group into virtual columns.

Missing context / blind spots
  • ⚠️ No local ClickHouse build or executable was available. Findings follow concrete traces through the current code; executing the focused regressions below would complete runtime validation.
Findings

❌ Blockers

  • DeletionVectorTransform.cpp:31: An all-pass PREWHERE can leave an ordinary chunk with no columns and no applied_filter, which is misclassified as count-only. Shrinking it for positional deletes without recording a filter corrupts _row_number. For offset 100, five rows, and delete 102, the reported positions become [100, 101, 102, 103] instead of [100, 101, 103, 104]. Use an explicit count-only marker and preserve mappings for ordinary chunks.

⚠️ Majors

  • ParquetV3BlockInputFormat.cpp:457: Metadata counts newly enabled for bitmap deletes emit whole row groups. Counts grouped by virtual columns such as _path and _size then materialize them for every surviving row at once: _size alone needs roughly 900 MB for a hundred million rows. This replaces bounded Parquet subgroups with allocations that input_format_parquet_max_block_size no longer limits. Split spans before materialization or limit the shortcut to pipelines that keep chunks constant throughout.
Tests
  • ⚠️ Add a query selecting _row_number through an all-pass PREWHERE over positional deletes, including optimize_count_from_files = 0, and verify the surviving physical positions.
  • ⚠️ Add a count grouped by a file virtual column over a large row group with bitmap deletes, using a constrained memory limit and a small input_format_parquet_max_block_size.
Final Verdict

❌ Block — preserve physical row mappings outside true count-only reads and bound count chunks before downstream materialization; add the focused regressions above.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 1, 2026
ianton-ru and others added 2 commits October 1, 2026 12:04
`IcebergStreamingPositionDeleteTransform` builds a dense filter per chunk, so a `need_only_count` row-group chunk allocates one filter of that length. Deletion vectors and `use_roaring_bitmap_iceberg_positional_deletes` still use `DeletionVectorTransform`, which resizes const count chunks from the bitmap.

https: //github.com/ClickHouse/pull/122861
Co-authored-by: Cursor <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 0deefb046e55b9138360e0cf12adbbc4ed1af3ad was not compared: the CI logs cluster did not answer (exception 241, code 500: Code: 241. DB::Exception: (total) memory limit exceeded: would use 212.40 …).

See the job log for details.

ianton-ru and others added 2 commits October 26, 2026 13:32
…t-info-clone

Keep per-row-group `need_only_count` spans, loaded from `getFileFooter`. Count-from-files still uses `hasFilter` and skips bucketed reads and attached deletes.

Co-authored-by: Cursor <[email protected]>
`ObjectInfoInArchive` now takes `archive_entry_index`. The merge left `clone` on the old constructor, so the tidy and fast-test builds failed. Both clones also keep `file_bucket_info_from_query_condition_cache`.

https: //github.com/ClickHouse/pull/122861
https: //s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122861&sha=05aaf6851a0036b42e9c219697e147b73f057ce2&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29
Co-authored-by: Cursor <[email protected]>
if (!isColumnConst(*column))
return false;
}
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Preserve row mappings for ordinary chunks with no columns

An empty column list also passes this check, but it does not imply need_only_count. For example, SELECT _row_number FROM icebergLocal(...) PREWHERE id >= 0 can remove id from the format's output header. When every row in a subgroup passes PREWHERE, ReadManager::read emits a chunk with no columns and no applied_filter. This branch then removes positional deletes by shrinking the row count, without recording which positions were removed.

For five rows starting at offset 100 with position 102 deleted, the surviving chunk has four rows and still has no filter, so VirtualColumnUtils produces _row_number = [100, 101, 102, 103] instead of [100, 101, 103, 104]. This affects deletion vectors and bitmap position deletes even with optimize_count_from_files = 0.

Please identify actual count-only chunks explicitly and retain the ordinary filtering/mapping path for other chunks, including empty-column chunks. Add a regression selecting _row_number through an all-pass PREWHERE over a file with positional deletes.


reported_count = true;
const auto & row_group = need_only_count_row_groups[need_only_count_next++];
auto chunk = getChunkForCount(row_group.num_rows);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Bound count chunks before downstream virtual columns materialize them

Enabling this path for files with bitmap deletes changes their output from bounded Parquet subgroups to an entire row group per chunk. The bitmap transform is allocation-free, but downstream consumers are not: StorageObjectStorageSource::generate calls addRequestedFileLikeStorageVirtualsToChunk, which materializes virtual columns with convertToFullColumnIfConst.

Consequently, SELECT _path, _size, count() FROM icebergLocal(...) GROUP BY _path, _size over a file with a deletion vector now materializes _size as Nullable(UInt64) for every surviving row of the whole row group, plus the _path dictionary indexes. A row group with a hundred million rows needs roughly 900 MB for _size alone, whereas the previous decode path emitted subgroups bounded by input_format_parquet_max_block_size. Reducing that setting no longer bounds this allocation, so previously bounded queries can exceed their memory limit.

Please split metadata count spans into bounded chunks before any materializing transform, or restrict the large-chunk shortcut to pipelines that preserve constant/count-only chunks throughout. Cover a virtual-column count over a large row group with deletes under a constrained memory limit.

@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... external Author is not a member of the ClickHouse organization pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants