Skip to content

Read the Hive partition columns from the path in a direct SELECT from S3Queue and AzureQueue - #131975

Merged
PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/s3queue-direct-select-hive-columns
Nov 20, 2026
Merged

PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/s3queue-direct-select-hive-columns

Conversation

@groeneai

@groeneai groeneai commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #131571 (comment)

Changelog category (leave one):

  • Improvement

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

A direct SELECT from an S3Queue or AzureQueue table with use_hive_partitioning = 1 now takes the Hive partition columns from the file path, as the materialized view path and the s3 table function do.

Description

With enable_object_storage_queue_hive_partitioning = 1, a direct SELECT c0, k FROM queue (stream_like_engine_allow_direct_select = 1) over k=abc/data.jsonl returns k = '', or the file's own k when the file has one, while a materialized view over the same table and s3(...) return abc. WHERE k = 'abc' returns no rows. No related open issue found; it came up in the S3Queue question on #131571.

StorageObjectStorageQueue::read called prepareReadingFromFormat without the PrepareReadingFromFormatHiveParams that streamToViews passes, so the format read the Hive columns from the file and the source never appended them from the path. The change passes the same parameters. A table without Hive columns gets empty parameters, which is the previous call. Improvement rather than Bug Fix: queue Hive columns are behind the experimental setting above.

The same call change is part of the open #105774 (positional reads), where its column mapping needs it; this PR lands it alone with a regression test. A subcolumn of a Hive column (k.null) now fails with NOT_FOUND_COLUMN_IN_BLOCK, as it already does for s3(); #124392 fixes that for all file-like storages.

The test fails on master (1 '', 2 file) and passes with the fix (50/50 randomized); the S3Queue tests runnable here pass. Also checked: SELECT *, _path, column order, a Bool key with bool_true_representation, Nullable and LowCardinality keys, commit_on_select = 1, a table without Hive columns, and the materialized view path (unchanged).

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.12.1.89-master (included in 26.12 and later)

…ueue

A direct SELECT from an S3Queue/AzureQueue table with use_hive_partitioning = 1
called prepareReadingFromFormat without PrepareReadingFromFormatHiveParams, so
the Hive columns were treated as file columns: the format returned the file's
value or the column default, and ObjectStorageQueueSource never appended the
value from the path. streamToViews already passes these parameters, which is
why a materialized view over the same table was correct.

Pass the same parameters in StorageObjectStorageQueue::read. A table without
Hive columns has empty file_columns and an empty map, which prepareReadingFromFormat
treats like the previous default call.

The same call change is part of the open ClickHouse#105774, where positional reads need it.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings;
bounded: 1 full pass + 1 fix round + 1 delta recheck), plus my own cold review of the diff (0 blocker, 0 major).

# Sev Finding Verdict Evidence / action
- - none - Gate B covered the changed file, prepareReadingFromFormat, ObjectStorageQueueSource, the shared S3/Azure registration, the Hive utilities and the sibling read paths.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-self-slot-58:20261116-113103

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @kssenii, could you review this? StorageObjectStorageQueue::read now passes the same PrepareReadingFromFormatHiveParams as streamToViews, so a direct SELECT from S3Queue/AzureQueue with use_hive_partitioning = 1 takes the Hive partition columns from the path instead of reading them from the file.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes: the new test fails on master 50/50 with the same diff (1 '', 2 file instead of 1 abc, 2 xyz).
b Root cause explained? StorageObjectStorageQueue::read called prepareReadingFromFormat without the Hive parameters streamToViews passes, so Hive columns were read from the file (default or file value) instead of the path.
c Fix matches root cause? Yes: the direct-SELECT call now passes the same PrepareReadingFromFormatHiveParams; the rest is the code the materialized view path already uses.
d Test intent preserved / new tests added? New stateless test, one fixture of two objects; the second file has its own k, so the test also checks that the path wins.
e Both directions demonstrated? Yes: master build 0/50, fix build 50/50, randomized settings, same server config, Build IDs checked.
f Fix is general across code paths? streamToViews, S3/File/URL reads already pass these parameters; AzureQueue is the same class; other streaming engines have no Hive partitioning; the queue path filter uses virtual columns only.
g Fix generalizes across inputs (params/datatypes/wrappers)? Checked String, Bool with bool_true_representation, Nullable, LowCardinality keys, column order, SELECT *, _path, count(), WHERE on the key, commit_on_select = 1. k.null now matches s3() (#124392).
h Backward compatible? (maintainer-approved exception only) No setting, format or Keeper change. A table without Hive columns gets the same prepareReadingFromFormat input as before.
i Invariants and contracts preserved? ReadFromFormatInfo is built by prepareReadingFromFormat as for the materialized view path (format header without Hive columns, Hive columns appended by the same source); the two storage members are set once in the constructor.

Session id: cron:clickhouse-impl-self-slot-57:20261116-105900

@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6c82fc2]

Summary: ❌

job_name test_name status info comment
Fast test (arm_darwin) FAIL
05042_crash_handler_without_global_context FAIL cidb, issue

AI Review

Summary

Direct SELECT from S3Queue and AzureQueue now reads Hive partition columns from object paths, matching the materialized view reader. The focused test covers missing and conflicting file values. One previously reported regression remains in head 6c82fc2fdb39dbe8333fcc1457e7cd51470f2368: defaults depending on a partition column can make valid files disappear from direct query results.

Findings

❌ Blockers

  • StorageObjectStorageQueue.cpp:784–790 — Preserve defaults depending on Hive partition columns. [dismissed by author -- Read the Hive partition columns from the path in a direct SELECT from S3Queue and AzureQueue #131975 (comment)]

    With schema (c0 Int32, k String, d String DEFAULT k) and k=abc/data.jsonl containing {"c0":1,"k":"abc"}, a direct SELECT c0, k, d previously returned 1, 'abc', 'abc'. The new parameters remove k from the format header and column description. StorageObjectStorageSource::createReader installs AddingDefaultsTransform before ObjectStorageQueueSource::generateImpl appends path columns. Evaluating the omitted d therefore raises UNKNOWN_IDENTIFIER; the first-block error handler skips the file in unordered mode. With commit_on_select = 1, that read failure also consumes file retries and can mark the file permanently failed.

    Why retained: the shared readers' existing limitation does not prevent this change from breaking a previously working direct read. The current code still has that ordering; the author deferred the issue, and a maintainer resolved the thread. No thread reply or reopening is warranted.

    Suggested fix: make path columns available before evaluating dependent defaults, including transitive dependencies.

Tests
  • ⚠️ Add a focused stateless regression using d String DEFAULT k, checking the returned row and path-derived default. Include a transitive default and verify that commit_on_select = 1 does not turn the valid fixture into a failed file. The new two-column test cannot detect this regression.
Missing context / blind spots
  • ⚠️ Runtime checks were not repeated: this checkout has no ClickHouse build or executable. The finding was verified by tracing the current reader, default evaluation, and queue error/commit paths, alongside the author's reproduction in the existing thread. Running the focused regression against this head would close the runtime verification gap.
Final Verdict

Status: ❌ Block

Make partition values available to dependent defaults and add the focused regression coverage above.

@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements can be tested Allows running workflows for external contributors labels Nov 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6c82fc2fd with master e05308f1d (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline.

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-s3queue S3Queue/AzureQueue engines (queue-based ingestion from object storage). label Nov 16, 2026
@PedroTadim PedroTadim self-assigned this Nov 20, 2026
@PedroTadim
PedroTadim enabled auto-merge November 20, 2026 16:46
@PedroTadim
PedroTadim added this pull request to the merge queue Nov 20, 2026
Merged via the queue into ClickHouse:master with commit 48dd41b Nov 20, 2026
193 of 195 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 20, 2026
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-s3queue S3Queue/AzureQueue engines (queue-based ingestion from object storage). pr-improvement Pull request with some product improvements 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.

3 participants