From ef5438b118252a5dea104fce52d7fd81694bee35 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 13 Jun 2024 14:19:00 +0200 Subject: [PATCH] wtf: Simplify SQL statement `shard_allocation` > This looks unreasonable complicated to just translate the primary boolean > into a string. Co-authored-by: Sebastian Utz --- cratedb_toolkit/wtf/library.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cratedb_toolkit/wtf/library.py b/cratedb_toolkit/wtf/library.py index 555cf035..765c7c88 100644 --- a/cratedb_toolkit/wtf/library.py +++ b/cratedb_toolkit/wtf/library.py @@ -423,16 +423,11 @@ class Shards: name="shard_allocation", sql=""" SELECT - IF(s.primary = TRUE, 'primary', 'replica') AS shard_type, - COALESCE(shards, 0) AS shards - FROM - UNNEST([true, false]) s(primary) - LEFT JOIN ( - SELECT primary, COUNT(*) AS shards + IF(primary = TRUE, 'primary', 'replica') AS shard_type, + COUNT(*) AS shards FROM sys.allocations WHERE current_state != 'STARTED' GROUP BY 1 - ) a ON s.primary = a.primary; """, label="Shard Allocation", description="Support identifying issues with shard allocation.",