mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #26913 from PolyProgrammist/table-function-cluster-macros
Supported cluster macros inside table function 'cluster'
This commit is contained in:
commit
c18c16855a
@ -12,6 +12,7 @@
|
||||
#include <Interpreters/IdentifierSemantic.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
#include <Common/parseRemoteDescription.h>
|
||||
#include <Common/Macros.h>
|
||||
#include <TableFunctions/TableFunctionFactory.h>
|
||||
#include <Core/Defines.h>
|
||||
#include <common/range.h>
|
||||
@ -156,10 +157,11 @@ void TableFunctionRemote::parseArguments(const ASTPtr & ast_function, ContextPtr
|
||||
if (!cluster_name.empty())
|
||||
{
|
||||
/// Use an existing cluster from the main config
|
||||
String cluster_name_expanded = context->getMacros()->expand(cluster_name);
|
||||
if (name != "clusterAllReplicas")
|
||||
cluster = context->getCluster(cluster_name);
|
||||
cluster = context->getCluster(cluster_name_expanded);
|
||||
else
|
||||
cluster = context->getCluster(cluster_name)->getClusterWithReplicasAsShards(context->getSettings());
|
||||
cluster = context->getCluster(cluster_name_expanded)->getClusterWithReplicasAsShards(context->getSettings());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
<yandex>
|
||||
<macros>
|
||||
<test>Hello, world!</test>
|
||||
<default_cluster_macro>test_shard_localhost</default_cluster_macro>
|
||||
<shard>s1</shard>
|
||||
<replica>r1</replica>
|
||||
<default_path_test>/clickhouse/tables/{database}/{shard}/</default_path_test>
|
||||
|
@ -0,0 +1,2 @@
|
||||
1
|
||||
1
|
@ -0,0 +1,2 @@
|
||||
SELECT _shard_num FROM cluster("{default_cluster_macro}", system.one);
|
||||
SELECT _shard_num FROM clusterAllReplicas("{default_cluster_macro}", system.one);
|
Loading…
Reference in New Issue
Block a user