Add a test for #48881, but it shows a bug with Parallel Replicas#80310
Conversation
|
Issue related to failed test in CI run with PR - #80440 |
|
Workflow [PR], commit [bfa8ad2] Summary: ✅
AI ReviewSummaryThe PR adds a regression test for PR Metadata
### Changelog category (leave one):
- Bug Fix
### Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix `MULTIPLE_EXPRESSIONS_FOR_ALIAS` for parallel-replica queries with duplicate projection aliases inside nested subqueries.Findings💡 Nits
Final Verdict✅ No code-level blockers found. Please fix the PR metadata before merge. |
|
@devcrafter, a problem with parallel replicas. |
|
Dear @alexey-milovidov, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
|
Dear @alexey-milovidov, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
The test uses `SELECT *, day + 365 AS day` which triggers `MULTIPLE_EXPRESSIONS_FOR_ALIAS` under Parallel Replicas due to a known analyzer bug (#80440). Tag with `no-parallel-replicas` to avoid the unrelated failure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
|
@groeneai, the Stress test (amd_asan_ubsan) failure on Could you investigate the failure and provide a fix in a separate PR? If a fix is already in progress, please link it here. |
…y_analysis Issue #74324 (`MULTIPLE_EXPRESSIONS_FOR_ALIAS` under parallel replicas) was closed by the fix #103806, so the old comment ("remove this guard once #74324 is fixed") is misleading: it invites removing the guard now that #74324 is closed. However, #103806 covered other shapes of that bug, not the self-shadowing alias used by this test (`SELECT *, day + 365 AS day`, where `day` is also a column). Verified locally against master with #103806 present: under forced parallel replicas the remote replica's analyzer still sees two bodies for the alias `day` and throws `MULTIPLE_EXPRESSIONS_FOR_ALIAS`. The `SET enable_parallel_replicas = 0` guard is therefore still required for this test to stay green in the `ParallelReplicas` CI suite (the in-query `SET` overrides the suite-level forcing). Auto-PR statistics mode (`automatic_parallel_replicas_mode = 2`) already passes, since it does not actually execute with parallel replicas. Update the comment to state this accurately and tie removal of the guard to the analyzer handling this shape, not to #74324 being closed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Updated the branch onto current `master` (was 574 commits behind), which now includes the merged #103806. I verified the parallel-replicas situation empirically on a fresh build at `3c6ba95806e` (includes #103806), running the test queries against `test_cluster_one_shard_three_replicas_localhost` with `enable_parallel_replicas = 1, max_parallel_replicas = 3`:
So #103806 covered the `PREWHERE`-alias and `SELECT *`-over-JOIN shapes, but not this self-shadowing alias over `SELECT *`. The explicit guard is therefore still required, and the comment in the test is accurate. Note that #74324 is currently closed as completed by #103806, yet this shape still reproduces — it may warrant reopening or a follow-up issue. The only CI failure is the chronic `Assertion 'px != 0' failed` terminate in `QueryPlanResourceHolder.cpp` (STID 3685-4830), triggered by an unrelated fuzzer query (`SELECT DISTINCT 1025, toFixedString(...)`) and tracked under #106079 — unrelated to this test-only change. |
|
Updated the branch onto current Re-verified the parallel-replicas situation on a fresh master build (rev
So the explicit guard is still required and the comment in the test remains accurate. #74324 is still effectively open for this self-shadowing shape — #103806 covered the |
…l replicas The self-shadowing alias shape `SELECT *, day + 365 AS day` serializes to `__table3.day AS day, __table3.day + 365 AS day` — the same alias `day` bound to two different bodies. When the analyzed query tree is converted back to AST and dispatched to a remote replica for parallel replicas, the receiver's analyzer re-resolves it and throws `MULTIPLE_EXPRESSIONS_FOR_ALIAS` (issue #74324). `queryNodeToDistributedSelectQuery` already deduplicated such aliases — stripping the alias on the later, different-body occurrence — but only on the top-level `SELECT`. In `SELECT count() FROM (... SELECT *, day + 365 AS day ...)` the conflict lives in a nested subquery, which the dedup never reached, so the query still failed. The reproduction from #48881 hits exactly this shape. Apply the dedup recursively to every `SELECT` in the dispatched AST. Each subquery is its own alias scope and the whole AST is re-analyzed on the receiver, so the conflict can arise at any nesting level. The same-alias-same-body duplicates are still preserved (only different bodies are stripped) to avoid `THERE_IS_NO_COLUMN` on the receiver, and an outer reference to the alias binds to the first occurrence regardless, so stripping the later alias is safe. This unblocks `03517_wrong_primary_key_analysis` (test for #48881), which now runs deterministically with parallel replicas instead of needing an explicit `enable_parallel_replicas = 0` guard. Refs #74324
|
Fixed the parallel-replicas bug so the test runs with parallel replicas (the explicit Root cause. The self-shadowing alias shape Fix ( Verified locally against a three-replica cluster (
This effectively completes #74324 for the self-shadowing-alias-over- Also updated the branch onto current @groeneai, the |
|
@alexey-milovidov yes, fix is in flight: #106664. STID 2651-3359 ( Root cause: when Fix in #106664: gate Session: cron:clickhouse-ci-task-worker:20260607-080600 |
LLVM Coverage ReportChanged lines: Changed C/C++ lines covered by tests: 23/25 (92.00%) | Lost baseline coverage: none · Uncovered code |

Closes: #48881
Related: #74324
Related: #103806
This started as a regression test for #48881 (wrong primary key analysis with an offset on the order field). Adding the test surfaced a
MULTIPLE_EXPRESSIONS_FOR_ALIASexception under parallel replicas for queries with self-shadowing projection aliases such asSELECT *, day + 365 AS day.#103806 deduplicated conflicting projection aliases only on the top-level
SELECTof the dispatched query, so the conflict was still reachable when it lived in a nested subquery (exactly the shape of the #48881 repro:SELECT count() FROM (... SELECT *, day + 365 AS day ...)). This PR refactors the deduplication (deduplicateProjectionAliases) to walk everySELECTat any nesting level of the dispatched AST, so the test now runs with parallel replicas enabled.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
MULTIPLE_EXPRESSIONS_FOR_ALIASexception for queries with duplicate projection aliases (for exampleSELECT *, day + 365 AS day) inside nested subqueries when running with parallel replicas.Version info
26.6.1.526