Skip to content

Commit 5981945

Browse files
authored
Merge pull request ClickHouse#79368 from tuanpach/select-important-fields-in-show-cluster
Select important fields instead of all for query 'SHOW CLUSTER <name>'
2 parents ea44b21 + ee9842a commit 5981945

File tree

6 files changed

+10
-18
lines changed

6 files changed

+10
-18
lines changed

docs/en/sql-reference/statements/show.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ The `SHOW CLUSTER(S)` statement returns a list of clusters.
500500
All available clusters are listed in the [`system.clusters`](../../operations/system-tables/clusters.md) table.
501501

502502
:::note
503-
The `SHOW CLUSTER name` query displays the contents of `system.clusters` table for the specified cluster name.
503+
The `SHOW CLUSTER name` query displays `cluster`, `shard_num`, `replica_num`, `host_name`, `host_address`, and `port` of the `system.clusters` table for the specified cluster name.
504504
:::
505505

506506
### Syntax {#syntax-20}
@@ -546,16 +546,10 @@ Row 1:
546546
──────
547547
cluster: test_shard_localhost
548548
shard_num: 1
549-
shard_weight: 1
550549
replica_num: 1
551550
host_name: localhost
552551
host_address: 127.0.0.1
553552
port: 9000
554-
is_local: 1
555-
user: default
556-
default_database:
557-
errors_count: 0
558-
estimated_recovery_time: 0
559553
```
560554

561555
## SHOW SETTINGS {#show-settings}

src/Interpreters/InterpreterShowTablesQuery.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
8787
if (query.cluster)
8888
{
8989
WriteBufferFromOwnString rewritten_query;
90-
rewritten_query << "SELECT * FROM system.clusters";
90+
rewritten_query
91+
<< "SELECT cluster, shard_num, replica_num, host_name, host_address, port FROM system.clusters";
9192

9293
auto cluster_name_expanded = getContext()->getMacros()->expand(query.cluster_str);
9394

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
test_shard_bind_host
2-
test_cluster_one_shard_two_replicas 1 1 0 1 127.0.0.1 127.0.0.1 9000 1
3-
test_cluster_one_shard_two_replicas 1 1 0 2 127.0.0.2 127.0.0.2 9000 0
2+
test_cluster_one_shard_two_replicas 1 1 127.0.0.1 127.0.0.1 9000
3+
test_cluster_one_shard_two_replicas 1 2 127.0.0.2 127.0.0.2 9000

tests/queries/0_stateless/01293_show_clusters.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
77
$CLICKHOUSE_CLIENT -q "show clusters like 'test_shard%' limit 1"
88
# cluster,shard_num,shard_weight,internal_replication,replica_num,host_name,host_address,port,is_local,user,default_database[,errors_count,slowdowns_count,estimated_recovery_time]
99
# use a cluster with static IPv4
10-
$CLICKHOUSE_CLIENT -q "show cluster 'test_cluster_one_shard_two_replicas'" | cut -f-10
10+
$CLICKHOUSE_CLIENT -q "show cluster 'test_cluster_one_shard_two_replicas'"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Output of: SHOW CLUSTER '{default_cluster_macro}'
2-
test_shard_localhost 1 1 0 1 localhost 9000 1
2+
test_shard_localhost 1 1 localhost 9000
33
to match Output of: SHOW CLUSTER 'test_shard_localhost'
4-
test_shard_localhost 1 1 0 1 localhost 9000 1
4+
test_shard_localhost 1 1 localhost 9000

tests/queries/0_stateless/03409_show_cluster_with_macros.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
66

77
echo "Output of: SHOW CLUSTER '{default_cluster_macro}'"
88

9-
# cluster,shard_num,shard_name,shard_weight,internal_replication,replica_num,host_name,[host_address,]port,is_local,user[,default_database,errors_count,slowdowns_count,estimated_recovery_time,...]
10-
# skipping "host_address" makes the test insensitive to IPv4/IPv6 addresses
11-
12-
$CLICKHOUSE_CLIENT -q "show cluster '{default_cluster_macro}'" | cut -f-7,9-10
9+
$CLICKHOUSE_CLIENT -q "show cluster '{default_cluster_macro}'" | cut -f1-4,6
1310

1411
echo "to match Output of: SHOW CLUSTER 'test_shard_localhost'"
1512

16-
$CLICKHOUSE_CLIENT -q "show cluster 'test_shard_localhost'" | cut -f-7,9-10
13+
$CLICKHOUSE_CLIENT -q "show cluster 'test_shard_localhost'" | cut -f1-4,6

0 commit comments

Comments
 (0)