From a4b1fc3062a496a3b5ed3134aa7da9f24ca1d90c Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Mon, 11 Mar 2024 22:26:59 -0400 Subject: [PATCH] add database query to cluster request --- sql/cluster.sql | 2 +- sql/cluster.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/cluster.sql b/sql/cluster.sql index 73ee7a5..2f2061c 100644 --- a/sql/cluster.sql +++ b/sql/cluster.sql @@ -6,7 +6,7 @@ SELECT formatReadableSize(sum(primary_key_bytes_in_memory)) AS primary_keys_size, any(engine) AS engine, sum(bytes) AS bytes_size -FROM clusterAllReplicas(default, system.parts) +FROM clusterAllReplicas({database: String}, system.parts) WHERE active GROUP BY database, diff --git a/sql/cluster.ts b/sql/cluster.ts index 156dbe5..783431b 100644 --- a/sql/cluster.ts +++ b/sql/cluster.ts @@ -1,5 +1,6 @@ import { z } from "zod"; import { readOnlyClient } from "../src/clickhouse/createClient.js"; +import { config } from "../src/config.js"; export const ClusterSchema = z.object({ count: z.number(), @@ -13,6 +14,6 @@ export type ClusterSchema = z.infer; export async function cluster() { const query = await Bun.file(import.meta.dirname + "/cluster.sql").text() - const response = await readOnlyClient.query({ query, format: "JSONEachRow" }); + const response = await readOnlyClient.query({ query, query_params: {database: config.database}, format: "JSONEachRow" }); return response.json(); }