Skip to content

Populate _etag virtual column for S3Queue/ObjectStorageQueue - #108625

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-108605-s3queue-etag-virtual-column
Jun 27, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-108605-s3queue-etag-virtual-column

Conversation

@groeneai

@groeneai groeneai commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #108605

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):

Fixed the _etag virtual column for the S3Queue and AzureQueue table engines: it was declared but never populated, so SELECT _etag always returned an empty string. It now returns the object ETag, like the S3 engine and the s3() table function.

Description

The _etag virtual column is declared for ObjectStorageQueue engines (S3Queue, AzureQueue) through the shared file-like virtual column list, but the read path in ObjectStorageQueueSource built the virtuals struct without the etag pointer. Since VirtualsForFileLikeStorage::etag defaults to nullptr, _etag was always filled with a default empty string. The plain S3 engine and the s3() function populate it correctly.

The ETag is already in scope at the call site (object_metadata->etag, also used to build the deduplication token a few lines above), so this just forwards it, mirroring StorageObjectStorageSource.

Note: _tags is also omitted at the same call site, but the queue iterator lists objects with with_tags = false, so tags are genuinely not fetched on the queue read path. Populating _tags would be a separate, larger change and is out of scope here.

Reproduction (reported on 26.4, still present on master): SELECT _etag from an S3Queue/AzureQueue table (directly or via a materialized view) returns an empty string instead of the object ETag.

Version info

  • Merged into: 26.7.1.140

The _etag virtual column is declared for ObjectStorageQueue engines
(S3Queue, AzureQueue) via the shared file-like virtual column list, but
the read path built the virtuals struct without the etag pointer, so
SELECT _etag always returned an empty string. The plain S3 engine and
the s3() function fill it correctly.

The etag is already available at that point (object_metadata->etag, also
used for the deduplication token), so this just passes it through, the
same way StorageObjectStorageSource does.

A regression test is added to test_storage_s3_queue test_virtual_columns:
it now also reads _etag and asserts it is non-empty. The test fails
before this change (empty etag) and passes after.

Closes: ClickHouse#108605

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SELECT _etag from an S3Queue table (via the test's materialized view) returns '' on every run. Demonstrated deterministically by the extended integration test test_storage_s3_queue/test_0.py::test_virtual_columns (assert res_etag != "").
b Root cause explained? ObjectStorageQueueSource built the VirtualsForFileLikeStorage struct without the etag pointer. VirtualsForFileLikeStorage::etag defaults to nullptr, and addRequestedFileLikeStorageVirtualsToChunk fills _etag with a default empty string when the pointer is null. So _etag was always empty, even though the ETag was already in scope (object_metadata->etag, used for the dedup token a few lines above).
c Fix matches root cause? Yes. The fix passes .etag = &(object_metadata->etag) into the struct, exactly the mechanism the S3 engine uses (StorageObjectStorageSource). No band-aid.
d Test intent preserved / new tests added? Yes. Extended the existing test_virtual_columns (which already covers _path/_file/_size/_time) to also read _etag and assert it is non-empty. No existing assertion weakened.
e Both directions demonstrated? Yes. Without the fix: FAILED ... AssertionError: assert '' != '' (Build ID 468176700acb...). With the fix: 1 passed (Build ID 312e051783e6...).
f Fix is general across code paths? The same call site also omits .tags, but the queue iterator lists with with_tags = false, so tags are genuinely not fetched on the queue path; populating _tags is a separate, larger change and is out of scope. _etag is the only file-like virtual that is both fetched and dropped here. The plain S3 path already populates .etag.
g Fix generalizes across inputs (params/datatypes/wrappers)? _etag is a single String virtual column produced from ObjectMetadata::etag, the same value the dedup-token path already consumes. No datatype/wrapper variants apply; the value is forwarded unchanged (raw quoted ETag, identical to the S3 engine).
h Backward compatible? (maintainer-approved exception only) Yes. No setting, format, or on-disk/wire change. _etag was already declared; this only starts populating a column that previously always returned empty. No SettingsChangesHistory.cpp change needed.
i Invariants and contracts preserved? Yes. addRequestedFileLikeStorageVirtualsToChunk takes etag as const String * and copies it into a const column; the pointed-to object_metadata->etag outlives the call. Chunk column count/structure is unchanged from the S3 engine's behavior for the same requested virtuals.

Session id: cron:clickhouse-worker-slot-3:20260626-140700

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @kssenii @scanhex12 — could you review this? S3Queue/AzureQueue declared the _etag virtual column but ObjectStorageQueueSource built the virtuals struct without the etag pointer, so SELECT _etag always returned empty. The fix forwards object_metadata->etag (already in scope for the dedup token), mirroring StorageObjectStorageSource. Closes #108605.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [17ac157]

Summary: ✅


AI Review

Summary

This PR fixes ObjectStorageQueueSource to pass ObjectMetadata::etag into file-like virtual column materialization, so S3Queue/AzureQueue _etag no longer materializes as the default empty string, and extends the S3Queue virtual-column integration test. I did not find any correctness, safety, or PR metadata issues that need inline comments.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.50% 77.60% +0.10%

Changed lines: Changed C/C++ lines covered by tests: 7/7 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 3 line(s) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 17ac157

CI fully finished: Finish Workflow and Mergeable Check pass; 0 test-level FAIL/ERROR in CIDB on this commit. The only red check is the ClickHouse Inc private sync, which is not actionable from the public fork.

Check / test Reason Owner / fixing PR
CH Inc sync private fork mirror CH Inc sync (private, not actionable by us)

Session id: cron:our-pr-ci-monitor:20260626-183000

@alexey-milovidov alexey-milovidov self-assigned this Jun 27, 2026
@alexey-milovidov
alexey-milovidov merged commit c49808f into ClickHouse:master Jun 27, 2026
166 of 167 checks passed
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai

Thanks!

Any other columns we don't populate? E.g., tags? If there are any, please send a fix.

@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov Audited the ObjectStorageQueue read path against the shared file-like virtual column list.

  • _tags is the one real gap: declared but never filled. Unlike _etag (returned for free by ListObjectsV2), object tags need a separate per-object GetObjectTagging call, so the plain S3 path fetches them on demand only when _tags is selected (StorageObjectStorageSource::createReader). The queue lists with with_tags=false and never tops them up, so SELECT _tags always returns {}. Sending a fix that mirrors the plain path: fetch tags once per file, only when _tags is requested. It is S3-only, since Azure's getObjectMetadata does not expose blob tags (AzureQueue _tags stays empty, same as the plain Azure path today).
  • _data_lake_snapshot_version and _iceberg_metadata_file_path are also declared via the shared list but are genuinely N/A for queue engines: they read plain objects with no Iceberg/Delta metadata, so there is no value to populate.
  • The rest are populated: _path, _file, _size, _time, _etag, _table, _row_number.

PR to follow.

zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…5-s3queue-etag-virtual-column

Populate _etag virtual column for S3Queue/ObjectStorageQueue
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 pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S3Queue: _etag virtual column is declared but never populated (always empty)

4 participants