Skip to content

Do not answer count() from part metadata for a STREAM read - #117188

Merged
alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:no-projection-for-stream-count
Sep 20, 2026
Merged

alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:no-projection-for-stream-count

Conversation

@groeneai

@groeneai groeneai commented Aug 30, 2026 •

Copy link
Copy Markdown
Collaborator

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 SELECT count() returning the whole-table row count for a streaming read (FROM ... STREAM), ignoring the CURSOR bound. The implicit min-max/count projection answered the query from part metadata instead of the streaming reader.

Description

Related: #112968 (comment). @ alexey-milovidov asked me to investigate this AST fuzzer (amd_release, oracle) failure and fix it separately. No open issue.

What breaks. A bare count() over a streaming read returns the whole-table count, ignoring the cursor:

SET enable_streaming_queries = 1;
-- 15 rows, in blocks 1, 2, 3
SELECT count()    FROM t STREAM BOUNDED CURSOR {'all': {'block_number': 1000000}};  -- 15, wrong
SELECT countIf(1) FROM t STREAM BOUNDED CURSOR {'all': {'block_number': 1000000}};  -- 0, correct

Root cause. canUseProjectionForReadingStep, the shared eligibility gate for both projection passes, declines FINAL and SAMPLE reads but never tested for a streaming read. A streaming read resolves its rows at runtime from the subscription bounds and the cursor, and plan-time part selection is skipped, so a metadata-derived count describes the whole table. The sibling rewrite already states the invariant: hasTrivialCountIncompatibleModifiers disqualifies hasFinal(), sampling and hasStream(); the projection gate had only the first two.

The change. One isStream() guard in that shared gate, spelled as in optimizeReadInOrder, optimizeLazyMaterialization, optimizeJoin and makeDistributed. It only declines an optimization, so it cannot change an already-correct result.

Validation. New stateless test; it fails 5/5 on the unpatched binary and passes 50/50 randomized runs. Every other metadata-count rewrite is guarded, or unreachable for a streaming read: optimizeTrivialCountFromTextIndex needs parts and a built text index, and a stream leaves both empty.

Releases. Measured on official builds (below): the setting does not exist on 26.3; 26.6, 26.7 and 26.8 are all affected, so v26.6-must-backport is the label to apply. The guard cherry-picks verbatim onto all three. The test does not: it needs STREAM BOUNDED, which parses only from 26.8, and on 26.6/26.7 no streaming spelling lets an aggregate terminate.

Two of the seven error runs in that job are different oracles (hasPhrase; LowCardinality LEFT JOIN), not addressed here.

The fuzzer failure this reproduces, and per-branch reachability

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112968&sha=386bab40257e0a7e157b6a5bc84c59092dcbfd60&name_0=PR&name_1=AST%20fuzzer%20%28amd_release%2C%20oracle%29

The TLP Aggregate oracle compares a reference count against the sum of three WHERE-carrying
partitions of the same read. Only the bare reference count is eligible for the metadata shortcut, so
the reference reported the whole table while the partitions summed to the correctly bounded number.
The oracle was reporting a real wrong result. The same mismatch appeared on
#111273 with block_number: 1000.

Reachability, measured on official builds from builds.clickhouse.com; 15 rows in blocks 1, 2, 3;
cursor block_number is an inclusive lower bound, so 1 admits every block and 1000000 none.

branch version plain STREAM CURSOR STREAM BOUNDED CURSOR
26.3 26.3.27.4 setting unknown, Code: 115 setting unknown
26.6 26.6.4.50 affected BOUNDED does not parse
26.7 26.7.6.48 affected BOUNDED does not parse
26.8 26.8.2.2 affected affected, wrong number shown directly

BOUNDED is absent from the STREAM grammar before 26.8 and nothing substitutes for it, so on 26.6
and 26.7 an aggregate over a streaming read never terminates and the correct count cannot be
obtained there. What is measurable on those two branches is that EXPLAIN shows the streaming read
replaced by ReadFromPreparedSource (_minmax_count_projection), and that count() returns the same
15 for a cursor admitting every block and one admitting none, so the bound is provably ignored. On
26.8 that identical signature co-occurs with the wrong number itself: count() 15, countIf(1) 0,
and 0 again with the projection disabled.

Closes #119420
Related: #119599


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

A bare SELECT count() over a streaming read returned the whole-table row
count and ignored the CURSOR bound:

    SET enable_streaming_queries = 1;
    -- 15 rows, in blocks 1, 2, 3
    SELECT count()    FROM t STREAM BOUNDED CURSOR {'all': {'block_number': 1000000}};  -- 15
    SELECT countIf(1) FROM t STREAM BOUNDED CURSOR {'all': {'block_number': 1000000}};  -- 0

canUseProjectionForReadingStep is the shared eligibility gate for the
aggregate and the normal projection pass. It declines reads whose shape a
projection cannot reproduce, including isQueryWithFinal() and
isQueryWithSampling(), but it never tested isStream().

A streaming read resolves which rows it returns at runtime, from the
subscription bounds and the cursor, so plan-time part selection is skipped
for it (ReadFromMergeTree::applyFilters and selectRangesToRead both return
early for a stream). The implicit min-max/count projection therefore
replaced the only streaming-aware step with a count derived from part
metadata, which describes the whole table.

PlannerJoinTree::hasTrivialCountIncompatibleModifiers already states the
invariant for the sibling trivial-count rewrite: FINAL, sampling and STREAM
all reshape the row set under the count. The projection gate tested the first
two and not the third. This adds it, spelled as in optimizeReadInOrder,
optimizeLazyMaterialization, optimizeJoin and makeDistributed.

The guard only declines an optimization, so it cannot change the result of
a query that was already correct, and non-streaming plans are unaffected.

Found by the TLP Aggregate oracle of the server-side AST fuzzer, which
compares a reference count against the sum of three WHERE-carrying
partitions of the same read. Only the bare reference count is
shortcut-eligible, so the reference reported the whole table while the
partitions summed to the correctly bounded number.

The new test asserts against countIf(1), which cannot take the shortcut,
and pins optimize_use_projections and optimize_use_implicit_projections
because the test runner randomizes the latter and it is forced off when the
former is off. Without that pin the test passes on the unpatched binary in
the runs where the shortcut is disabled. The non-streaming control arm also
disables optimize_trivial_count_query, because with it enabled a bare
non-streaming count() is answered at plan-build time and no ReadFromMergeTree
survives for the projection pass to act on.

Two of its arms name a specific cursor block number, so the test needs the
three inserts to receive local increment block numbers; it is tagged
no-shared-merge-tree for that reason, as the other streaming tests with the
same dependency are.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Aug 30, 2026
@groeneai

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

Every round before publication paired an independent cold model review of the tree (engine codex)
with my own cold review of the resulting code.

# Sev Finding Verdict Evidence / action
1 ❌ The test filename breaks the streaming-test naming rule, so Style check would fail AGREE, fixed ci/jobs/check_style.py:213-232 errors when a 0_stateless test matching enable_streaming_queries\s*=?\s*(0|1|true|false) has no _streaming_queries_ in its basename. Both files renamed. Reported as a nit; I raised it to a blocker because the consequence is mechanical. A passing test run cannot see this class, so the style checks are now run locally, each with a control.
2 ⚠️ The non-streaming control accepts any ReadFromPreparedSource, so it does not prove the min-max projection is armed AGREE, fixed optimize_trivial_count_query defaults to true and applyTrivialCountIfPossible emits its own prepared source at plan-build time (PlannerJoinTree.cpp:650), before any projection pass. Measured: the old arm returned 1 even with the projection disarmed. The control now disables that setting and asserts _minmax_count_projection; disarming the projection makes it fail 3/3. The reddening arms were never affected: STREAM is declined for the trivial count at PlannerJoinTree.cpp:513, which is why the projection pass was reached at all.
3 ⚠️ The Bug Fix (... official stable release) category asserted a release fact that nothing in the pull request measured AGREE, fixed Reachability is now measured per active release branch on official builds, each with a positive control (countIf(1), which cannot take the shortcut) and a negative control (optimize_use_implicit_projections = 0). See the Releases note in the description.
4 💡 The test hardcodes cursor block numbers but carried no no-shared-merge-tree tag AGREE, fixed The tag is honoured only in the cloud lane (tests/clickhouse-test:2931-2936), so no open-source lane was at risk, but the in-tree streaming tests that depend on block numbering carry it (04235_streaming_queries_merge_tree_cursors, 04235_streaming_queries_merge_tree_order and 04726_streaming_queries_commit_order_snapshot_plan among them), and I cannot verify SharedMergeTree block numbering from this tree. Added.
5 💡 The added comment said a projection "answers from part metadata", which is exact only for the implicit projections AGREE, fixed The same gate also declines normal projections, which substitute a projection-part read (optimizeUseNormalProjection.cpp:748). Reworded to say a projection describes the whole table, same three lines.
6 💡 A test comment claimed the runner randomizes enable_analyzer AGREE, fixed It does not: the setting is absent from SettingsRandomizer.settings. The SET is needed because the old-analyzer lane turns the alias off as a profile default (tests/config/users.d/analyzer.xml:4). Comment corrected.
7 ⚠️ The stated reason for pinning optimize_trivial_count_query = 0 in the control arm was inverted, in the test comment and in the commit message AGREE, fixed It reads as though the pin prevents a spurious pass. It prevents a spurious failure: applyTrivialCountIfPossible sets its step description to Optimized trivial count (PlannerJoinTree.cpp:651) and adds it to the plan, so no ReadFromMergeTree survives for the projection pass and the arm's _minmax_count_projection pattern cannot match. With the setting at its default the arm returns 0. The framing was accurate for the arm's earlier, broader pattern and was not updated when finding 2 replaced it. Rewritten as a standing invariant in both places.
8 ⚠️ The commit message counted "two metadata-count rewrite sites", which is wrong and contradicts the description AGREE, fixed More sites than that answer a count from part metadata or an index: applyTrivialCountIfPossible (PlannerJoinTree.cpp:538), applyTrivialCountWithSparsityFilterIfPossible (:661), optimizeTrivialCountFromTextIndex (:330), the old-analyzer getTrivialCount (InterpreterSelectQuery.cpp:2720) and the projection gate itself. The description names the text-index one, so the two artifacts disagreed. The tally is also doing no work, since "two of the three" refers to the modifiers, so it is removed and the modifier argument kept. Row (f) below enumerates the sites by name and asserts no total, which is the form that survives someone adding a sixth.
9 ⚠️ The Releases note said the test "needs re-pointing at plain STREAM" on 26.6 and 26.7, contradicting the reachability block in the same description AGREE, fixed No streaming spelling lets an aggregate terminate on those branches, which the collapsed block already said, so the remedy offered to whoever handles the backport could not work. The note now says the test does not port below 26.8 and why. The guard itself does cherry-pick verbatim.
10 💡 The setup comment says that with the projection pinned off "every query below reads through the reader", which is too broad AGREE, not fixed True of the streaming queries, which is what the pin protects, but the non-streaming count() would instead be answered by the independent trivial-count rewrite (PlannerJoinTree.cpp:649-652), as the control comment further down states. The conclusion the clause supports, that the test cannot observe the bug without the pin, is measured: with the pin the test fails 3/3 on the unpatched binary under adversarial injection, without it 3/3 pass. Left as is; the over-broad quantifier is confined to a test setup comment.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal
per finding.

Noted, not fixed here:

  • optimizeTrivialCountFromTextIndex's guardsHold has no isStream() test and does not need one:
    it requires a non-empty part list (:230) and built indexes (:238), and a streaming read has
    neither, because selectRangesToRead returns before either is populated
    (ReadFromMergeTree.cpp:3254). Probed with a positive control that proved the optimization does
    fire for the non-streaming shape, so a guard there would be dead code.
  • The streaming engine optimizes its own inner per-round plan with the table expression modifiers
    erased (MergeTreeCommitOrderSource.cpp:63, buildReadRoundPipeline.cpp:177), so no isStream()
    guard applies there. No count rewrite can fire on that plan, which carries no aggregation step.
  • If Answer min/max/count aggregations from per-part column statistics #115738 lands, the per-part statistics path it adds is another metadata answer for
    min/max/count and would need the same guard.

Session id: cron:clickhouse-review-slot-9:20260830-185100

@clickhouse-gh clickhouse-gh Bot closed this Aug 30, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [11c1ae9]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

This PR makes canUseProjectionForReadingStep reject STREAM reads, which prevents the implicit min-max/count projection from answering count() from whole-table metadata after the cursor/runtime stream bounds have narrowed the read. The added stateless test checks the wrong-result case, the bounded no-cursor case, and a non-streaming control; on the current diff I did not find a remaining correctness, compatibility, or test-coverage gap.

Final Verdict

✅ No new findings in the current diff. No inline review comments were posted.

LLVM Coverage Report

Measured on commit 11c1ae9.

Metric Baseline Current Δ
Lines 88.40% 88.40% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 80.60% 80.60% +0.00%

Changed lines: Changed C/C++ lines covered: 6/6 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SELECT count() FROM t STREAM BOUNDED CURSOR {'all': {'block_number': 1000000}} returns 15 instead of 0 on every run, with no fuzzer and no randomization.
b Root cause explained? Yes. canUseProjectionForReadingStep is the shared eligibility gate for both projection passes. It declines FINAL and SAMPLE but never tested for a streaming read. A streaming read resolves its rows at runtime from the subscription bounds and the cursor, and plan-time part selection is skipped for it, so the implicit min-max/count projection replaced the only streaming-aware step with a whole-table metadata count and the cursor bound was dropped.
c Fix matches root cause? Yes. The rewrite is declined at the eligibility gate, beside the sibling FINAL/SAMPLE guards, mirroring the invariant hasTrivialCountIncompatibleModifiers already states for the trivial-count rewrite. No widened bound, no no-random-* tag, no guard at the point of use.
d Test intent preserved / new tests added? Yes. No existing test weakened or removed. One new stateless test, which asserts against countIf(1) because that spelling cannot take the shortcut, and which pins the settings that arm the shortcut so it cannot pass vacuously. Its non-streaming control arm was measured load-bearing rather than assumed: disarming the projection makes that arm return 0 and the test fail. The style checks were also run locally, each with a control confirming the check scans this file.
e Both directions demonstrated? Yes. 5/5 FAIL on the unpatched binary and 50/50 OK with the fix, each on a server whose buildId() was asserted against the binary before the verdict. On the unpatched binary the failure reddens the three streaming arms and leaves the control arm unchanged, as a control must.
f Fix is general across code paths? Yes. One guard in the shared gate covers both the aggregate and the normal projection pass. Every other metadata-count rewrite was enumerated: trivial count in the analyzer is already guarded by hasStream(), the old analyzer rejects streaming outright, the text-index count is unreachable for streams (verified with a positive control that the optimization does fire on a non-streaming read), and lazy materialization, read-in-order, join, distributed and parallel replicas each already carry the guard.
g Fix generalizes across inputs? Yes for the axis that applies. The cursor bound is the relevant input: the test covers no cursor, a mid-table bound returning some rows, a past-end bound returning none, and a non-streaming control. Type wrappers are not a factor, since the guard reads a boolean on the table expression modifier and inspects neither column types nor the aggregate arguments.
h Backward compatible? (maintainer-approved exception only) Yes. No setting default change, so SettingsChangesHistory.cpp is untouched, and no format change. The guard only declines an optimization, so no query that was already correct can change its result; non-streaming count() was measured unchanged. Release reachability was measured on official builds rather than asserted: affected on 26.6, 26.7 and 26.8, and not on 26.3, where enable_streaming_queries does not exist. Each verdict carries a positive control (countIf(1), which cannot take the shortcut) and a negative control (the same query with the implicit projection disabled).
i Invariants and contracts preserved? Yes. canUseProjectionForReadingStep is a side-effect-free predicate; the added branch is an early return false alongside four existing ones, before any state is read or built. No lifetime, locking or concurrency surface. Declining leaves the plan on the ordinary ReadFromMergeTree path, which is the path that already returned correct results.

Session id: cron:clickhouse-impl-slot-4:20260830-170300

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @antaljanosbenjamin @Michicosun, could you review this? canUseProjectionForReadingStep declines FINAL and SAMPLE reads but never tested isStream(), so the implicit min-max/count projection answered a bare count() over a streaming read from part metadata and the CURSOR bound was dropped.

@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing commit 11c1ae901edc9938c78a18ff8f833b9337bc8b2d with master failed: RuntimeError: CI logs cluster query failed: SELECT count() AS c FROM binary_sizes W….

See the job log for details.

… config so the upgrade check can start the previous release)
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger for 6e5703c

Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link will be
posted here when it opens. Only CH Inc sync is exempt.

Two PR workflow runs exist at this head (33330750285 and 33330757618, created 9 s apart), so the
table is the UNION of both failure sets rather than the one run that result_pr.json dedups to.

Check / test Reason Owner / fixing PR
AST fuzzer (amd_debug, targeted) / Sort order of blocks violated for column number 0, left: UInt64_999, right: UInt64_998 (STID 3413-350b) trunk defect; the same signature fires on unrelated heads and on master #108550 (ours, open)
AST fuzzer (amd_debug, targeted) / parts_ranges[0].event == PartsRangesIterator::EventType::RangeStart (STID 2508-4ab1) trunk defect in the parts splitter #116473 (ours, open)
AST fuzzer (amd_debug, targeted, old_compatibility) / Sort order of blocks violated ... (byte-identical message, no STID computed in this arm) same trunk defect as the first row #108550 (ours, open)
AST fuzzer (amd_debug, targeted, old_compatibility) / key_order.compareTuples(left_keys, right_keys, used_key_size) <= 0 (STID 2508-5166) trunk defect in primary-key index analysis #116473 (ours, open)
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) 9000 s job timeout, exit -15; the job result's own labels record IO stalled 8837.78s (98% of runtime) #116209 (ours, open)
Upgrade check (amd_release) / Cannot start clickhouse-server the previous-release server refuses to start: Code: 137 ... Unknown elements 'enable_silk_runtime', 'silk' found in config /etc/clickhouse-server/config.xml #117172 (ours, merged), merged master @ 81503ce

LLVM Coverage is DROPPED, not failed. It aggregates the coverage jobs' profraw artifacts, so it is a
cascade of the Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) timeout
above rather than an independent defect: on the sibling head 6b4fa927f8f6, whose coverage job
completed, the same node is success. Its owner is the same, #116209.

Master is merged at 81503ce58eb2 to pick up #117172, so the next run covers the
Upgrade check (amd_release) row. No other row in the table is affected by that merge.

Session id: cron:our-pr-ci-monitor:20260831-013002

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 81503ce58eb22bce36021911cc48c390ff764ebd

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, old analyzer, 2/6) / Container memory budget exceeded (/docker) the job's containers breach the /docker cgroup budget and the kernel kills processes inside it, so the shard errors at job level #117202 (external, merged 2026-08-31 11:05:36Z), merged master @ 0ba019d8a771137ad123a712f9074811a757011c
Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) / Container memory budget exceeded (/docker) same signature #117202 (external, merged 2026-08-31 11:05:36Z), merged master @ 0ba019d8a771137ad123a712f9074811a757011c
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) same signature #117202 (external, merged 2026-08-31 11:05:36Z), merged master @ 0ba019d8a771137ad123a712f9074811a757011c

Those three shards are the only failures at this head, and one condition explains all of them. None
can be caused by this PR: its diff is src/Processors/QueryPlan/Optimizations/projectionsCommon.cpp
plus its own stateless test, which cannot change how much memory the containers of an unrelated
integration module use. #117202 serializes the shutdown gdb attach whose fan-out drives the cgroup
over budget.

This head predates that fix: 7fc3004ed25a2dc8aa66428f4f010244dea3046a is not an ancestor of
81503ce58eb2 (the fix side is 150 commits ahead), so I merged master in at
3bfee6a80b1078391ca7e18d51eed444d1e5c996 to pick it up and CI is re-running. The merge is a pure
master merge: it adds no commit of my own, the resulting tree is byte-identical to the tree I merged
locally, its first parent is the pre-merge head, and no contrib/ submodule pin moved.

CH Inc sync was success at this head, so nothing here is exempt.

Session id: cron:our-pr-ci-monitor:20260831-153000

@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 0ba019d8a771137ad123a712f9074811a757011c

Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link I will post here when it opens.

Check / test Reason Owner / fixing PR
Bugfix validation (functional tests, amd64) infra: the job asserts Could not find master builds in S3 (ci/jobs/functional_tests.py:734) and ERRORs before running anything a fix task is in progress (fixing PR link to follow here)
Bugfix validation (functional tests, aarch64) same infra assert a fix task is in progress (fixing PR link to follow here)
Finish Workflow / Post Hooks cascade of the two rows above: new_tests_check.py needs at least one Bugfix validation job to report OK or XFAIL, and both ERRORed a fix task is in progress (fixing PR link to follow here)
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, parallel, 1/3) / 03707_autopr_unsupported_cases trunk: the autopr positive canaries report 0 0 in the old-analyzer lane (84 unrelated PRs, 109 runs, 12 true-master hits in 14d) #117364 (external, merged 2026-08-31 22:05Z), not yet on this branch
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) host memory over-commit: the /docker cgroup leaf OOM-kills the nested containers and the whole shard loses its signal (244 PRs, 305 runs, 25 true-master hits in 7d) a fix task owns it at P1 (fixing PR link to follow here)

None of these is caused by this PR. #117202 is already on this branch, so it does not cover the container-memory signature. I am holding the master merge for #117364 until the Bugfix validation infra fix lands, so one merge picks up both.

Session id: cron:our-pr-ci-monitor:20260901-003000

@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Bugfix validation / Finish Workflow red on this pull request (Could not find master builds in S3): #117433. The reference master binaries moved to REFs/master/<sha>/masterci/build_<type>/clickhouse when the artifact prefix gained a workflow-name segment, and find_master_builds still spelled the old path.

@Algunenano

Copy link
Copy Markdown
Member

@groeneai Please fix the build after merging master

The STREAM guard was written when the function returned bool. Master changed the
return type to std::expected<void, std::string>, whose failure arm carries the
reason string that EXPLAIN projections = 1 reports for each rejected projection,
so 'return false' no longer converts and the translation unit fails to compile.

Return the reason the way every sibling guard in the same function does. The
wording mirrors "the query uses FINAL" / "the query uses SAMPLE" because
STREAM is likewise a SQL construct on the read rather than a property of the
table or of the settings.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixed in 509ac19 (plain push, your merge commit untouched).

Master changed canUseProjectionForReadingStep to return std::expected<void, std::string>, so the STREAM guard's return false; stopped converting. It now returns std::unexpected("the query uses STREAM") like the sibling FINAL/SAMPLE guards, so the reason also shows up in EXPLAIN projections = 1. That was the only error in the job (1 occurrence of : error: in the arm_tidy log); the rest of the workflow was dropped behind it.

Verified on the merged head: 05054_streaming_queries_count_not_from_metadata passes 3/3 with the change, and fails without it (count() returns 15 instead of 0).

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 509ac19

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (amd_asan_ubsan, db disk, 7/8) infra: Failed to pre-pull Docker images needed by the test batch, after 3 attempts at pull access denied for minio/mc, repository does not exist (that Docker Hub repository was deleted upstream) #119999 (mine, merged 2026-09-16 14:42:43Z), merged master @ 11c1ae901edc9938c78a18ff8f833b9337bc8b2d
Finish Workflow / Post Hooks cascade of the row above same owner, #119999
Mergeable Check / PR aggregator cascade of the row above same owner, #119999

The failing job started at 13:26Z, before that fix merged, so master is merged here to pick it up. The mirrored clickhouse/minio-mc tag was pushed at 14:39Z and pulls fine now. Only shard 7/8 is affected, because its batch is the one that pulls minio/mc.

Session id: cron:our-pr-ci-monitor:20260916-153030

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 11c1ae9

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build profile diff infra, and not this commit: the job's own read from the CI logs cluster failed (RuntimeError: CI logs cluster query failed at build_profile_diff_job.py:234, raised through has_pr_data :723 on the binary_sizes query). Fleet-wide: across all pull requests this check recorded 0 successes and 122 errors between 15:00Z and 20:00Z today #120121 (mine, open)
PR (commit status) aggregator cascade of the row above: all 173 check-runs on this head are complete (154 success, 18 skipped, 1 failure) and Mergeable Check is green same owner, #120121

The underlying cluster error is not visible in the report because line 234 raises a wrapper without the response body. #118708 (mine, open) is the reporting half of the same family.

Session id: cron:our-pr-ci-monitor:20260916-203057

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 19, 2026
Merged via the queue into ClickHouse:master with commit f738709 Sep 20, 2026
176 of 178 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 20, 2026
leshikus pushed a commit to leshikus/ClickHouse that referenced this pull request Oct 27, 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-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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.

AST fuzzer: TLP Aggregate oracle mismatch with STREAM BOUNDED UNORDERED CURSOR

4 participants