Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Analyzer/Resolve/resolveFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,11 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
///
/// `getSetting` and `rowNumberInAllBlocks` are non-deterministic but must NOT be shared: the cache
/// is global across scopes, and e.g. `SETTINGS` can change `getSetting`'s result for every scope.
///
/// Server constants (`hostName`, `serverUUID`, ...) capture `Context::isDistributed` when built.
/// A local `UNION` branch and a later cluster branch must not share that instance.
if (function && !function->isDeterministic()
&& !function->isServerConstant()
&& function_name != "getSetting" && function_name != "rowNumberInAllBlocks")
{
auto hash = function_node_ptr->getTreeHash();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 1 1
2 2 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- A local GROUP BY hostName() must not be reused for a later cluster branch.
-- hostName() is folded on the local branch and must stay a per-shard column on the cluster branch.

SELECT tag, c, h = hostName()
FROM
(
SELECT hostName() AS h, count() AS c, 1 AS tag
FROM numbers(1)
GROUP BY h
UNION ALL
SELECT hostName() AS h, count() AS c, 2 AS tag
FROM cluster('test_cluster_two_shards', system.one)
GROUP BY h
)
ORDER BY tag;
Loading