Repository navigation
Conversation
`hostName` captured `Context::isDistributed` from the first `UNION` branch and was then folded on a cluster branch, so the `GROUP BY` headers no longer matched. Co-authored-by: Cursor <[email protected]>
|
Workflow [PR], commit [bdf2a85] Summary: ❌
AI ReviewSummaryThe PR prevents server constants built for a local query from being reused in a distributed Findings❌ Blockers
Tests
Final Verdict❌ Block — preserve within-scope sharing of server constants and add regression coverage. |
| if (function && !function->isDeterministic() && !function->isStateful() | ||
| && function->isDeterministicInScopeOfQuery()) | ||
| && function->isDeterministicInScopeOfQuery() | ||
| && !function->isServerConstant()) |
There was a problem hiding this comment.
[Blocker] Preserve server-constant sharing within each scope
isServerConstant also covers uptime, which captures Context::getUptimeSeconds in its constructor. Excluding it from the cache entirely gives repeated expressions and alias expansions different snapshots within the same scope. Reproduced with this PR's fast-test binary:
SELECT uptime() AS u, (SELECT sleep(2)) AS delay, toString(u) AS u_string;This returns u = 0, delay = 0, and u_string = '2': converting the alias changes its value. Replacing the last expression with uptime() AS u also makes this valid query throw AMBIGUOUS_COLUMN_NAME because the constants disagree. A slow scalar subquery is enough to trigger this on a running server; the explicit delay just makes it reproducible.
Keep server constants in a cache keyed by their scope/context so repeated uses within a scope share the captured value and local/distributed branches get separate instances. Please add a regression covering this within-scope consistency.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 18 s compile time in total, 7 of them have a recent master baseline. |
hostNamecapturedContext::isDistributedfrom the firstUNIONbranch and was then folded on a cluster branch, so theGROUP BYheaders no longer matched.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
UNIONof a local query andcluster()(or another cluster function) throwingNUMBER_OF_COLUMNS_DOESNT_MATCHorTHERE_IS_NO_COLUMNonGROUP BY hostName. A server constant built on the local branch was reused for the cluster branch and folded to the initiator value. Each scope now builds its own value, so shards report their ownhostName,serverUUID,tcpPort, and the other server constants.Workflow [PR]
Sync PR [sync-upstream/pr/123523]