Repository navigation
Make the row order of 03323_union_all_constants_bug deterministic - #125872
Algunenano merged 1 commit into
Conversation
Both UNION ALL branches return a row with grade_name_id = 42 and the query sorted only by grade_name_id, so the two rows tied. MergingSortedTransform breaks ties by merge input index, so the output order depended on which input carried which row; two unrelated PRs got the rows swapped in Stateless tests (arm_binary, parallel) and (amd_debug, parallel). Add `flag ASC NULLS FIRST` as a tiebreaker. The reference is unchanged, and grade_name_id stays the first key so the union keeps the constant column the test exists for (ClickHouse#75715): EXPLAIN PIPELINE header = 1 is identical and EXPLAIN PLAN differs only in the sort description. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings), plus my own cold review of the diff (0 findings). Nothing to adjudicate: the change is a one-line Session id: cron:clickhouse-review-slot-9:20261014-203800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261014-202100 |
|
Workflow [PR], commit [3ba31f7] Summary: ✅ AI ReviewSummaryAdds Final VerdictStatus: ✅ Approve |
|
cc @CurtizJ, could you review this and add the |
6a78f52
Related: #75715
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not required (CI fix).
Description
03323_union_all_constants_bugfailed withresult differs with referenceon two unrelated PRs, with the two output rows swapped (arm_binary report, amd_debug report).Both
UNION ALLbranches return a row withgrade_name_id = 42, and the query ends withORDER BY grade_name_id ASC, so the rows tie and their order is unspecified. The merge of the sorted streams breaks ties by input index, so the result depends on which input each row arrives on. Writing the branches in the opposite order gives exactly the CI diff on every run.The fix adds a tiebreaker,
ORDER BY grade_name_id ASC, flag ASC NULLS FIRST, which keeps the current.reference.grade_name_idstays the first key, so the union still carries the constant column that #75715 is about:EXPLAIN PIPELINE header = 1is identical before and after, andEXPLAIN PLANdiffers only in the sort description.Validation: with the branches swapped, the old
ORDER BYreturns the CI diff and the new one returns the reference, under both failing CI settings strings andmax_threads1 and 32. 500 randomized runs pass, and so do 4800 runs withmax_threads = 32and the failing settings.Workflow [PR]
Sync PR [sync-upstream/pr/125872]
Version info
26.10.1.2473-master(included in26.10and later)