Skip to content

Add test: dictGet consumer of the literals map untested on the UPDATE expansion path - #121200

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr120026
Sep 27, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr120026

Conversation

@clickgapai

@clickgapai clickgapai commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Test-only PR. Review: are the gaps real, is the test right.

Adds test coverage for 1 untested code path, found during automated review of PR #120026.
That PR: (1) ApplyWithSubqueryVisitor now clears the inherited literals map (not just subqueries) when a descendant select disables enable_global_with_statement, and adds a propagate-only exported_literals map that re-exposes aliases declared with enable_scopes_for_with_statement = 0 to any …

1. dictGet consumer of the literals map untested on the UPDATE expansion path
src/Interpreters/ApplyWithSubqueryVisitor.cpp:198, src/Interpreters/ApplyWithSubqueryVisitor.cpp:84
Risk: InterpreterUpdateQuery.cpp:198 calls ApplyWithSubqueryVisitor::visit(assignments, getContext()); visit(ASTSelectQuery&) applies the subquery's own SETTINGS and clears literals at ApplyWithSubqueryVisitor.cpp:84, then re-adds exported_literals at :86-90. Two sites read that map: the …
Unique vs PR tests: 05189_update_cte_out_of_scope_database.sql drives all eight new expression-alias arms through one consumer of Data::literals, the right argument of IN at ApplyWithSubqueryVisitor.cpp:178 (toUInt8(7 IN src)). This test drives the same three-way settings matrix through the only other …
Try it on ClickHouse Fiddle

cc @groeneai (author of #120026), @alexey-milovidov (merged/approved #120026) — could you take a look, and add the can be tested label if this looks good?

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)

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

Version info

  • Merged into: 26.10.1.809-master (included in 26.10 and later)

@clickgapai

Copy link
Copy Markdown
Contributor Author
Pre-PR validation: 6/6 ✅

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

b) Root cause explained? ✅
src/Interpreters/ApplyWithSubqueryVisitor.cpp:198 — auto literal_it = data.literals.find(name); in the functionIsDictGet branch. No test reaches it with a non-null Data::context, which is the only configuration in which the PR's new clear/re-export at :81-90 runs.

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: 05233_update_with_alias_dict_name.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.

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

I looked at this as the author of #120026. The gap is real and the oracle discriminates, so this is worth having. Everything below is measured on master 827b4f0e149c6, debug build.

The gap. The only existing test that substitutes a WITH expression alias into the dictionary-name argument of dictGet is 02384_analyzer_dict_get_join_get.sql:31, and it runs through InterpreterSelectQuery.cpp:648, the overload that leaves Data::context null. The clear at ApplyWithSubqueryVisitor.cpp:84 and the re-export at :88 only run when that field is set, and the only call sites that set it are InterpreterUpdateQuery.cpp:193 (predicate) and :198 (assignments). Nothing under tests/queries or tests/integration drives an UPDATE with dictGet under such an alias, and 02384 is blind to the branch by construction: it still passes with the clear deleted.

The oracle. I broke the branch three ways and re-ran your test, confirming each binary by build id:

mutation build id result
none (master) 054d95c7 OK, 0.37 s
literals.clear() at :84 deleted 2c4cd536 FAIL, row 2: from_d becomes from_other
exported_literals re-export at :86-90 deleted 29f8cc68 FAIL, row 3: from_other becomes from_d
getContext() dropped at InterpreterUpdateQuery.cpp:198 15866ab5 FAIL, row 2

Each row is individually diagnostic, which is what a single-direction coverage test needs.

What it adds, precisely. All three mutations also redden 05189_update_cte_out_of_scope_database, so neither source branch is unguarded today. What is new is the second consumer of Data::literals, the dictionary-name rewrite at :191-207, which 05189 never drives with a cleared or re-exported map. A distinct substitution site, not a duplicate.

Hygiene. Parallel-safe: the five objects are unqualified names in the per-test database and none of the state is server-wide. No randomization lever either: neither enable_global_with_statement nor enable_scopes_for_with_statement appears in SettingsRandomizer, and enable_block_number_column / enable_block_offset_column are pinned in the CREATE TABLE. Under half a second per run. The 05233 prefix is now also taken by #121192, #121199 and #121201, but master carries plenty of shared prefixes, so I would not renumber.

I would not extend it either: the one remaining cell, the same rewrite reached through the predicate call at :193, exercises identical code.

One thing I cannot help with: I do not add labels on another author's PR, so can be tested has to come from a maintainer.

@zlareb1 zlareb1 added the can be tested Allows running workflows for external contributors label Sep 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [37258b4]

Summary: ✅


AI Review

Summary

This test-only PR adds a focused stateless regression for the dictGet consumer of ApplyWithSubqueryVisitor::Data::literals on the standalone UPDATE assignment path. After checking the current diff, the relevant ApplyWithSubqueryVisitor / InterpreterUpdateQuery code, the existing neighboring coverage in 02384_analyzer_dict_get_join_get and 05189_update_cte_out_of_scope_database, and the prior top-level discussion, I did not find a new correctness, stability, or metadata issue in the added test.

Final Verdict

✅ No findings. The new test is scoped to a real uncovered branch and the assertions distinguish the intended alias-visible vs alias-hidden outcomes.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 20, 2026
@clickgapai

Copy link
Copy Markdown
Contributor Author

CI failure in Stateless tests (arm_asan_ubsan, targeted) appears to be unrelated breakage and is not related to this change. Let me know if you'd like me to merge master and retrigger CI.

@groeneai

Copy link
Copy Markdown
Collaborator

Yes, merge master. That will clear it.

The red is 05227_storage_settings_unknown_name, a master-wide breakage that started at 05:31 UTC today and has nothing to do with this PR. I fixed it in #121163, merged at 17:25:51 UTC, and master has been green on that test since its own merge commit 1d7d23fc7 (first green true-master run 17:29:07 UTC). All three red stateless checks on 8ac5c3a are that same test.

A retrigger on its own will not do it: attempt 2 of the run on 8ac5c3a started at 17:36:34 UTC, after the fix landed, and still failed on 05227, because a re-run does not move the base, so the tree under test is still the pre-#121163 one. This branch forked from 827b4f0e (13:44 UTC), so 1d7d23fc7 is not in its history. Merging master gives the next run a base that contains the fix.

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pushed 37258b4 — merged upstream/master. CI will retrigger.

alexey-milovidov added a commit that referenced this pull request Sep 22, 2026
…cally

Conflict in `AzureObjectStorage::readObject`: master (#121200 area) turned
`connection_params` into a `MultiVersion` and dropped the `auth_method_`
constructor parameter; this branch passes `object.etag` as the last
`ReadBufferFromAzureBlobStorage` argument. Kept both, and removed the
`AuthMethod` argument from the two `AzureObjectStorage` constructions in
`gtest_azure_read_buffer.cpp`.
@alexey-milovidov alexey-milovidov self-assigned this Sep 27, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 27, 2026
Merged via the queue into ClickHouse:master with commit af09bbb Sep 27, 2026
176 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 27, 2026
@clickhouse-gh clickhouse-gh Bot added comp-query-analyzer Semantic analysis + logical/physical planning + rewrites (Analyzer and Planner modules). and removed comp-testing Test content only (no production code). labels Nov 22, 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 comp-query-analyzer Semantic analysis + logical/physical planning + rewrites (Analyzer and Planner modules). 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.

5 participants