Skip to content

Add test: WindowStep frame serialization of end_preceding (flags |= 4) is untested for distributed plans - #112969

Merged
nihalzp merged 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr109802
Aug 2, 2026
Merged

nihalzp merged 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr109802

Conversation

@clickgapai

@clickgapai clickgapai commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #109802.
That PR The PR implements serialize/deserialize for WindowStep so window functions can run under make_distributed_plan=1, registers a "Window" step in QueryPlanStepRegistry, bumps DBMS_QUERY_PLAN_SERIALIZATION_VERSION to 4, and extends SortingStep serialization to carry `partition_by_descripti

1. WindowStep frame serialization of end_preceding (flags |= 4) is untested for distributed plans
src/Processors/QueryPlan/WindowStep.cpp:194, src/Processors/QueryPlan/WindowStep.cpp:213
Risk: serializeWindowFrame at WindowStep.cpp:193-194 sets bit 4 only when frame.end_preceding is true; deserializeWindowFrame:213 reads it back into frame.end_preceding. The PR's frame tests all use end_preceding=false (1 PRECEDING AND CURRENT ROW, ... AND N FOLLOWING), so this bit is never written or read. RISK: if the flag is dropped/mis-encoded, the deserialized frame silently reinterprets an end-PRECEDING boundary as end-FOLLOWING, producing WRONG window aggregation results for …
What's unique vs PR tests: The PR's 04506 rolling-frame test uses ROWS BETWEEN 1 PRECEDING AND CURRENT ROW (end_preceding=false); its other frames use ... AND N FOLLOWING (end_preceding=false). None exercise an end-PRECEDING boundary, so flags |= 4 (line 194) and its read at line 213 are only exercised by this test.
Tags: -- Tags: no-old-analyzer — no-old-analyzer: make_distributed_plan requires the analyzer; matches the PR's own window tests.
Try it on ClickHouse Fiddle

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

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

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
WindowStep.cpp:194 flags |= 4; (guarded by if (frame.end_preceding)) and its read at :213 frame.end_preceding = bool(flags & 4); — correct but exercised by no test.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04669_distributed_plan_window_end_preceding_frame.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 2, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8190eac]

Summary: ✅


AI Review

Summary

This PR adds a focused stateless test for the WindowStep distributed-plan serialization path where the window frame ends with PRECEDING (frame.end_preceding = true). The query shape and settings do exercise serialized distributed-plan execution, and the expected output would change materially if bit 4 were lost on serialize or deserialize, so I did not find a correctness or coverage problem in the test.

Final Verdict

✅ No material issues found.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 2, 2026
@nihalzp nihalzp self-assigned this Aug 2, 2026
@nihalzp
nihalzp added this pull request to the merge queue Aug 2, 2026
Merged via the queue into ClickHouse:master with commit 4c8a7fd Aug 2, 2026
180 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 2, 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 pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants