Repository navigation
Add a test for an unqualified dictGet in a SQL UDF used by an ALIAS column - #123563
Merged
PedroTadim merged 1 commit intoOct 3, 2026
Conversation
…olumn On 26.9.8.3 `CREATE TABLE` qualified table and dictionary names before expanding SQL UDFs and never after, so `v ALIAS f(id)` with `f = x -> dictGet(d, 'v', x)` was persisted as `dictGet(d, 'v', id)`. Every later reader resolved `d` against its own current database: a `SELECT` from another database failed with `Dictionary (d) not found`, and the mutation of a lightweight `DELETE` (analyzed in a background context) failed with Code 341 wrapping the same error. Master already persists `dictGet(<db>.d, 'v', id)` since ClickHouse#114923, which runs `AddDefaultDatabaseVisitor::visitTableExpressions` on the columns list after the UDF expansion. Its tests cover `dictGet` only in a view and `joinGet` in a `DEFAULT`, so this adds the issue's shape: an identifier-form `dictGet` from a UDF in an `ALIAS` column, read from another current database and by a lightweight `DELETE`. The test is a shell test because a SQL UDF is server-wide and `CREATE FUNCTION` takes no query parameter, so the name must be scoped by `${CLICKHOUSE_DATABASE}` to be safe under concurrent runs. Closes ClickHouse#123489 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) and an independent cold review of the same tree (0 blocker, 0 major findings). Nothing to adjudicate. Session id: cron:clickhouse-review-slot-9:20261002-144503 |
Collaborator
Author
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261002-142300 |
Contributor
|
Workflow [PR], commit [4e12ec6] Summary: ✅ AI ReviewSummaryThis PR adds a stateless shell regression test for issue Final Verdict
|
PedroTadim
approved these changes
Oct 2, 2026
PedroTadim
enabled auto-merge
October 2, 2026 15:11
|
Thank you for taking this up so quickly! |
valerypetrov
pushed a commit
to valerypetrov/ClickHouse
that referenced
this pull request
Nov 13, 2026
With the revert, the only caller of `addWithAliases` passes `only_recursive_with_hides_table = true`, so `collectWithExpressionAliases` is never called and `with_expression_aliases` is never written: `isExpressionAlias(name)` equals `expression_aliases.contains(name)` on every remaining path. Remove the parameter, the member and both helpers (added by ClickHouse#114908 for the removed pass); the full traversal behaves as before. The second sentence of the comment on the string overload of `qualifyDictionaryNameWithDatabase` named the removed metadata-load caller. 05233_udf_expansion_with_alias_scope (ClickHouse#114908) and 05317_udf_dictget_alias_column_lightweight_delete (ClickHouse#123563, issue ClickHouse#123489) test the qualification of the names a SQL UDF brings into a CREATE, which the revert removes; both fail on the revert commit and are deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #123489
Related: #114923
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not required.
Description
Requested by PedroTadim on the linked issue. Test only, no
src/change.What breaks. On 26.9.8.3, a table with
v ALIAS f(id)wheref = x -> dictGet(d, 'v', x)readsvfine from its own database, but a
SELECTfrom another current database fails withDictionary (d) not found, andDELETE FROM t WHERE id = 1fails with Code 341 wrapping the sameerror (its mutation runs in a background context whose current database is the server default).
Root cause. On 26.9,
CREATE TABLEqualified names before expanding SQL UDFs and never after, so thecolumn was persisted as
dictGet(d, 'v', id). Master persistsdictGet(<db>.d, 'v', id)since #114923,which qualifies the table expressions of the columns list after the UDF expansion. That PR's tests
cover
dictGetonly in a view andjoinGetin aDEFAULT; nothing covered this shape.Validation.
26.9.8.3: the test fails with the issue's two errors; the same script with the UDF bodyqualified (
dictGet(<db>.d, ...), the only change) passes, so the persisted spelling alone decides it.visitTableExpressions(*create.columns_list)call from Make a table read by a scalar subquery in a CONSTRAINT a loading dependency #114923 removed: failswith the same two errors; restored: passes.
${CLICKHOUSE_DATABASE}, which is why this is a.shtest).🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123563]
Version info
26.10.1.1359-master(included in26.10and later)