Skip to content

Make 04743_trivial_count_array_join_argument runnable on release branches without unnest - #115505

Merged
PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/04743-portable-drop-unnest-arms
Aug 20, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/04743-portable-drop-unnest-arms

Conversation

@groeneai

@groeneai groeneai commented Aug 19, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

Related: #115227

The test added by #115227 used unnest, a case-insensitive alias of arrayJoin registered only
since 8601d0ff817f (2026-05-16), after the 25.8 and 26.3 branch points. Both backports to those
branches fail the test with Code: 46 ... Function with name 'unnest' does not exist, while the
src/Planner fix itself cherry-picks cleanly.

It is worse than one red arm: all 19 statements of the main block are in a single client call, so
the abort at statement 2 skipped statements 3-19, including all four EXPLAIN plan assertions. On
those branches the test verified nothing.

This drops the two unnest arms from 04743 and relocates the alias coverage into
04241_alias_unnest, which is absent from exactly the branches that lack the alias. Nothing is
weakened: FunctionNode::resolveAsFunction stores the canonical name, so at the guard
(hasFunctionNode(aggregates.front(), "arrayJoin")) the two arms were indistinguishable -
measured, the surviving 20 reference lines are byte-identical with and without them. 04241 gains
a MergeTree trivial-count arm with an = 0 control that reddens on its own fixture when the guard
is deleted.

Validated on the backports' own CI binaries (release branch plus the guard), both directions on the
same binary: fails on 25.8/26.3 before, byte-equal to the reference after, with the 17 skipped
assertions now executing and agreeing. 26.5/26.6/26.7 stay byte-equal. On master both tests pass
clickhouse-test, 200/200 randomized and non-randomized, and deleting the guard reddens 7 of
04743's assertions.

This does not turn the already-open backports green: each is built from the parent's frozen merge
commit and #115227 is labelled pr-backports-created, so it is not re-processed. It fixes the file
for any re-created backport and for future PRs touching it.

Noted, not addressed: no-old-analyzer is unknown to tests/clickhouse-test before 26.6, where
unknown tags are ignored silently, and is unreachable there.

Per-branch validation matrix

Binaries are the backports' own build_amd_debug artifacts, each version-asserted before use.

branch binary 04743 before 04743 after 04241 after
25.8 (#115468) 25.8.31.1 FAIL UNKNOWN_FUNCTION, 4 of 22 lines byte-equal, empty stderr n/a (file absent)
26.3 (#115469) 26.3.20.8 FAIL UNKNOWN_FUNCTION, 4 of 22 lines byte-equal, empty stderr n/a (file absent)
26.5 (#115470) 26.5.8.4 passes byte-equal byte-equal
26.6 (#115471) 26.6.4.1 passes byte-equal byte-equal
26.7 (#115472) 26.7.5.1 passes byte-equal byte-equal
master 26.8.1.1 passes [ OK ] [ OK ]

04241_alias_unnest is absent from exactly the branches that lack the alias, which is why the
coverage can live there safely.

Guard-deletion mutation on master, 04743: reference lines 1-4 go 6/6/5/11 -> 3/3/3/3 (the
table's row count, i.e. the wrong result the guard prevents), line 14 0 -> 1 and line 15
1 -> 0 (the two EXPLAIN assertions), line 18 6 -> 0 (the file() arm). Same mutation,
04241: the new optimize_trivial_count_query = 1 arm goes 6 -> 3 while its = 0 control stays
6.


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

Version info

  • Merged into: 26.8.1.1738 (included in 26.8 and later)

…ches without unnest

The test added by ClickHouse#115227 used `unnest`, a case-insensitive alias of `arrayJoin` registered
only since 8601d0f (2026-05-16), i.e. after the 25.8 and 26.3 branch points. On those
branches the analyzer throws UNKNOWN_FUNCTION before the guard under test is reached, so the
backports of ClickHouse#115227 to 25.8 and 26.3 fail on the added test file while the src/Planner fix
itself cherry-picks cleanly.

All 19 statements of the main block are one client call, so the abort at statement 2 also
skipped statements 3-19: every optimize_trivial_count_query = 0 control, the four
"optimization is kept" arms and all four EXPLAIN plan assertions. Those backports therefore
carried no verification of the fix they exist to port.

Drop the two unnest arms from 04743 and relocate the alias coverage into 04241_alias_unnest,
which is absent from exactly the branches that lack the alias. This loses nothing at the
guard: FunctionNode::resolveAsFunction stores the canonical name, so hasFunctionNode(...,
"arrayJoin") sees the two arms identically, and the surviving 20 reference lines are
byte-identical with and without them. 04241 gains a MergeTree trivial-count arm with an
optimize_trivial_count_query = 0 control.

Validated on the backports' own CI build artifacts, both directions on the same binary:
25.8 and 26.3 fail before and are byte-equal to the reference after, with the 17 previously
skipped assertions now executing and agreeing; 26.5, 26.6 and 26.7 stay byte-equal. On master
both tests pass clickhouse-test, 200/200 over randomized and non-randomized runs. Deleting the
guard reddens 7 of 04743's assertions and flips the new 04241 arm from 6 to 3, so neither
file is vacuous.

This does not turn the already-open backports green: each is built from the parent's frozen
merge commit and ClickHouse#115227 carries pr-backports-created, so it is not re-processed.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Aug 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (2 findings raised, both refuted on measurement)

An independent model reviewed this diff cold. Both substantive findings were investigated and
declined; the evidence is below in case a reviewer wants to re-open either.

❌ "Still red in the old-analyzer jobs on 25.8/26.3/26.5, because those branches ignore
no-old-analyzer but schedule old-analyzer stateless jobs."
Declined: the tag really is inert
before 26.6, but those branches schedule no old-analyzer stateless job, so the file never runs
under enable_analyzer = 0 there.

⚠️ "The relocated 04241 arm passes whenever the optimization declines before reaching the
arrayJoin guard, so add exact EXPLAIN assertions there."
The mechanism is real, the
conclusion is not, and the remedy would reintroduce the problem this PR fixes.

  • Discriminating power is measured on that fixture, not argued: with the guard deleted and
    rebuilt, 04241 goes [ OK ] to [ FAIL ], the optimize_trivial_count_query = 1 arm
    returning 3 (the table row count, i.e. the wrong result) while the = 0 control stays 6.
  • The dilution is not reachable in CI. make_distributed_plan, enable_cascades_optimizer and
    empty_result_for_aggregation_by_empty_set all default to false, none is randomized by
    tests/clickhouse-test, and no file under tests/config/ sets any of them (the
    distributed plan flavor links users.d/distributed_plan.xml, which sets only
    serialize_query_plan). Both arms pin optimize_trivial_count_query per query.
  • Exact EXPLAIN assertions are what forced no-old-analyzer onto 04743 in the first place.
    04241 is untagged and does run in the old-analyzer stateless check on master, and the tag is
    inert before 26.6, so adding them would either red that check or need a tag that does not work
    on the branches this PR is about. A value assertion plus an = 0 control is the right shape
    here.

💡 A nit asked for the visible Related: #115227 line to be a full URL. The full URL is already
in the linked-issues comment block, where the template asks for it; the short form in the
description is there so the provenance link renders.

Also noted, not addressed: applyTrivialCountWithSparsityFilterIfPossible has no arrayJoin
guard, which is harmless because it accepts only a zero-argument count().

Session id: cron:clickhouse-review-slot-48:20260819-193200

@clickhouse-gh clickhouse-gh Bot closed this Aug 19, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, 100% and not a rate: run the pre-fix file against the 26.3 or 25.8 backport CI binary and it fails Code: 46 ... Function with name 'unnest' does not exist at resolveFunction.cpp:1322, emitting 4 of 22 reference lines.
b Root cause explained? Yes. unnest is a case-insensitive alias of arrayJoin registered at arrayJoin.cpp:271 by 8601d0ff817f (2026-05-16), after the 25.8/26.3 branch points, so on those branches function resolution throws before the guard under test is reached. Because all 19 statements of the main block are one client call, the abort also skipped statements 3-19.
c Fix matches root cause? Yes. The unportable construct is removed from the backported file and its coverage relocated into 04241_alias_unnest, which is absent from exactly the branches that lack the alias. No .reference rewrite, no tag, no widened bound.
d Test intent preserved / new tests added? Yes. 04743 keeps all 20 discriminating assertions and 7 of them flip when the guard is deleted. 04241 gains a MergeTree trivial-count alias arm plus an optimize_trivial_count_query = 0 control, and that arm flips 6 -> 3 on its own fixture under the same mutation.
e Both directions demonstrated? Yes, on the same binary per branch: 25.8 and 26.3 fail before the change and are byte-equal to the reference with empty stderr after it.
f Fix is general across code paths? Yes. Every construct 04743 uses was swept against all five active target branches with a positive control on each row; unnest was the only gap. All other in-tree unnest( users were checked and each lives in a file absent from the pre-26.5 branches.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for a test-portability fix: no new code path and no type or parameter surface. The dimension that matters is branches, and all five active targets plus master were measured on real binaries.
h Backward compatible? (maintainer-approved exception only) Yes. Test-only change, no setting, no serialization, no SettingsChangesHistory.cpp entry.
i Invariants and contracts preserved? Yes. The new .reference is byte-identical to the previous file with exactly lines 2 and 7 removed (diff <(sed '2d;7d' old) new is empty); the statement-to-line mapping was re-checked; 04241 uses a scoped table name and stays parallel-safe, so no no-parallel tag is introduced.

Session id: cron:clickhouse-impl-slot-4:20260819-172300

@clickhouse-gh

clickhouse-gh Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c97ca0b]

Summary: ✅


AI Review

Summary

This PR removes the two unnest assertions from 04743_trivial_count_array_join_argument and relocates the alias coverage into 04241_alias_unnest, so the backportable test no longer depends on a function alias that does not exist on older release branches. I did not find a correctness or coverage regression in the current diff: the 04743 reference stays consistent after deleting the duplicated alias arms, and the new 04241 queries still cover count(unnest(...)) with optimize_trivial_count_query both enabled and disabled.

Final Verdict

✅ No blocking issues found.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @yakov-olkhovskiy, could you review this? It is test-only: the test added by #115227 used unnest, an arrayJoin alias that only exists from 26.5, so on the 25.8 and 26.3 backports it aborted at the second statement and the remaining 17 assertions never ran. The two alias arms move to 04241_alias_unnest, which is absent from exactly those branches.

@clickhouse-gh

clickhouse-gh Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c97ca0bc9 with master caccecd78 (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
Binary Master PR Δ
programs/clickhouse-stripped 703.83 MiB 700.79 MiB -3.04 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

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

Job report

@PedroTadim PedroTadim self-assigned this Aug 20, 2026
@PedroTadim
PedroTadim added this pull request to the merge queue Aug 20, 2026
Merged via the queue into ClickHouse:master with commit 7881869 Aug 20, 2026
353 of 354 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 20, 2026
alexey-milovidov added a commit that referenced this pull request Aug 20, 2026
`unnest`, a case-insensitive alias of `arrayJoin`, was registered only in
8601d0f (2026-05-16), after the 25.8 branch point. On this branch the
analyzer throws `UNKNOWN_FUNCTION` at the second statement of the test's
single client call, which also skipped statements 3-19: every
`optimize_trivial_count_query = 0` control, the four "optimization is kept"
arms and all four `EXPLAIN` plan assertions. So the backport carried no
verification of the fix it exists to port.

This mirrors the master change c97ca0b (#115505), which dropped the two
`unnest` arms and relocated the alias coverage into `04241_alias_unnest` - a
test that does not exist on this branch, precisely because the alias does not.
Nothing is lost at the guard itself: `FunctionNode::resolveAsFunction` stores
the canonical name, so `hasFunctionNode(..., "arrayJoin")` sees the `unnest`
arms identically to the `arrayJoin` ones, and the surviving 20 reference lines
are byte-identical with and without them.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115468&sha=77b6ebb9c8604d45e2db4a7111e93258704076fa&name_0=BackportPR
Related: #115227
Related: #115505

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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 groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect pr-ci 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