Repository navigation
Conversation
Pre-PR Validation Gate (session
|
|
cc @KochetovNicolai @vdimir @novikd @alexey-milovidov — could you review? This extends the same early-exit pattern you established in #100401 to cover within-side duplicate column names (STID 4752-593c), for which the same join order optimizer fails with a similar logical error. Same one-liner style, same mechanism. |
|
Workflow [PR], commit [db2e87d] AI ReviewSummaryThis PR adds a stateless regression test for the join-order guard that skips reordering when a relation header contains duplicate column names. The added multi-join queries are directionally useful, but the file no longer contains the correlated-subquery query that the PR body identifies as the deterministic pre-fix reproducer, so the test-only change does not yet prove it would catch the reported regression. Findings
Tests
Final Verdict
|
LLVM Coverage Report
Changed lines: 100.00% (13/13) · Uncovered code |
d47fab6 to
56f5b2d
Compare
Update: rebased onto master, now test-onlyThis PR was rebased onto current master to clear a merge conflict. During the What remains is the regression test for the within-side Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-2:20260610-072600 |
56f5b2d to
592ed3e
Compare
592ed3e to
564a9fa
Compare
STID 4752-593c: a debug-build LOGICAL_ERROR "Input nodes size mismatch in dag" raised by the JoinExpressionActions constructor while the join order optimizer reconstructs a join. It fired when a relation's output header carried duplicate column names within one side (for example a subquery projecting the same alias twice, kept distinct by QUALIFY: SELECT 1 AS x, 2 AS y, x, y QUALIFY 7). foldActionsByProjection deduplicates INPUT nodes by name, so the folded DAG's input count no longer matched left_header.columns() + right_header.columns(). This is already fixed on master: PR ClickHouse#106418 (commit 2ddbf35) generalized the pre-reorder overlap guard into joinGraphHasOverlappingColumnNames, which feeds the output headers of every relation in the flattened join graph through a single shared name set and skips reordering on any duplicate, whether within one side or across sides. That subsumes the within-side case here, so no source change is needed. PR ClickHouse#106418's own test covers only the cross-side parallel-replicas manifestation; this adds coverage for the within-side QUALIFY/duplicate-projection manifestation. All queries verified passing on master HEAD. The greedy multi-join query pins query_plan_optimize_join_order_algorithm=greedy and query_plan_optimize_join_order_limit=16 so randomized stateless runs always exercise the greedy chooseJoinOrder path; a randomized limit of 0 or a dpsize-first algorithm list would otherwise skip it and stop covering the intended path. Co-Authored-By: Claude Opus 4.8 <[email protected]>
564a9fa to
c557528
Compare
CI summary for
|
| Check | Failure | Classification | Disposition |
|---|---|---|---|
| Stateless tests (arm_asan_ubsan, azure, parallel) | 13 unrelated tests (00049_any_left_join, 02406_minmax_behaviour, 04033_tpc_ds_q83, 03742_nested_loop_join_long, ...) | Azure infrastructure outage | Not PR-caused. The same check had 82 distinct failing tests across 18 unrelated PRs in the same window, the signature of an Azure backend outage. None overlap this PR's change. |
| Stateless tests (amd_llvm_coverage, old analyzer, s3, DatabaseReplicated, WasmEdge, parallel) | job-level failure, zero per-test FAIL rows | Coverage-job infra/timeout | Not PR-caused. No individual test failed; the job summary row alone is red. |
The PR's own added test 04327_join_optimizer_duplicate_column_names passed everywhere (zero FAIL/ERROR rows across all checks on this commit).
Session: cron:our-pr-ci-monitor:20260610-133000
| SET allow_experimental_correlated_subqueries = 1; | ||
|
|
||
| -- Header with a within-side duplicate (__table1.x, __table1.y, __table1.x, __table1.y). | ||
| SELECT x FROM (SELECT 1 AS x, 2 AS y, x, y QUALIFY 7) LIMIT 100 FORMAT Null; |
There was a problem hiding this comment.
This file drops the one query the PR body says is the deterministic reproducer on the broken commit (SELECT x, (SELECT y) FROM ...). SELECT x FROM (...) has no join at all, so it never reaches chooseJoinOrder, and the explicit joins below are only shown to pass on fixed master. Since this PR is test-only, it still needs at least one query that is demonstrated to fail before #106418 (or to keep the original correlated-subquery shape here); otherwise the regression does not prove it would catch the bug it claims to cover.
There was a problem hiding this comment.
Confirmed, and the problem is worse than described. I am closing this PR.
Both factual claims check out:
- Line 10 has no join.
EXPLAIN PLANisLimit -> ReadFromSystemOne, and a trace-level run
contains zero join-related lines, so it never reacheschooseJoinOrder. - The
SELECT x, (SELECT y) FROM (... QUALIFY 7)shape was dropped, and it is the shape that
builds a join carrying duplicate output names (Right: y, x, x, y).
Where I disagree is the remedy: restoring that query would not make this a regression test.
I ran every query in the file, plus the dropped one, against debug builds of the original
failing commit 2892de44 (26.4.1.1031) and of 0c27fffd, the parent of #106418, on a real
server. All of them pass on both. As a positive control on the same harness, #106418's own
test 04303_join_reorder_overlapping_names_parallel_replicas.sql aborts on 0c27fffd with
Logical error: 'Left and right columns have same names: [__table1.id], [__table1.id]' at
JoinExpressionActions.cpp:131 via chooseJoinOrder, so the harness does detect this class.
I also checked whether the file pins today's guard, by making
joinGraphHasOverlappingColumnNames at optimizeJoin.cpp:1541 skippable at runtime. The
mutation is reachable: with the guard off the plan reorders to t1[1] join t2 join t3, and
with it on the reorder is skipped. Even so, all four queries still pass with the guard
disabled. So nothing in this file fails without the fix, and the within-side manifestation
this PR was written for no longer reproduces on master by any shape I could construct
(explicit projection, t1.*, correlated (SELECT t1.y), the original fuzzer session
settings, and both join-order algorithms).
The underlying class is still live on master, but in the reorder-reconstruction path rather
than this one, and it already has a test that discriminates: #110227 adds
04516_join_reorder_duplicate_names_merge_expression, which crashes without its fix and
passes with it. That is the coverage worth having, so adding a file that passes
unconditionally here would only cost CI time.
|
Closing: the regression test in this PR does not regress, so it would add CI time without Verified on debug builds against a real server, with #106418's own test as a positive control
The last column disables The class is still live on master, but in the reorder-reconstruction path, and #110227 already |
Background
STID 4752-593c was a debug-build
LOGICAL_ERROR("Input nodes size mismatch in dag") from theJoinExpressionActionsconstructor during join order reconstruction. It fired when a relation's output header had duplicate column names within one side, for example a subquery projecting the same alias twice and kept distinct byQUALIFY:foldActionsByProjectiondeduplicates INPUT nodes by name, so the folded DAG's input count stopped matchingleft_header.columns() + right_header.columns().What changed
This PR originally carried a source fix. That is no longer needed: PR #106418 (commit
2ddbf356499) generalized the pre-reorder overlap guard intojoinGraphHasOverlappingColumnNames, which runs the output headers of every relation in the flattened join graph through a single shared name set and skips reordering on any duplicate, within one side or across sides. That subsumes the within-side case here.PR #106418's own test covers only the cross-side parallel-replicas manifestation. This PR now adds a regression test for the within-side
QUALIFY/ duplicate-projection manifestation, demonstrating that it no longer reproduces on master HEAD. The source change was dropped, so this is test-only.All three test queries pass on master HEAD (
fc73f46), 50/50 with--no-random-settings.Changelog category (leave one):