From 68795d0e20da54f7695d73c13f2b0c130b9c24e4 Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Thu, 28 Mar 2024 18:25:36 +0100 Subject: [PATCH] fix(debug): Restore order to CH query debug modal list (#21221) * fix(debug): Restore order to CH query debug modal list * Fix non-aggregated value usage --- ee/api/debug_ch_queries.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ee/api/debug_ch_queries.py b/ee/api/debug_ch_queries.py index 6c4b1746b425b..5599b52a8cf5f 100644 --- a/ee/api/debug_ch_queries.py +++ b/ee/api/debug_ch_queries.py @@ -31,8 +31,12 @@ def list(self, request): response = sync_execute( """ SELECT - query_id, argMax(query, type), argMax(query_start_time, type), argMax(exception, type), - argMax(query_duration_ms, type), max(type) AS status + query_id, + argMax(query, type) AS query, + argMax(query_start_time, type) AS query_start_time, + argMax(exception, type) AS exception, + argMax(query_duration_ms, type) AS query_duration_ms, + max(type) AS status FROM ( SELECT query_id, query, query_start_time, exception, query_duration_ms, toInt8(type) AS type @@ -41,10 +45,11 @@ def list(self, request): query LIKE %(query)s AND query NOT LIKE %(not_query)s AND query_start_time > %(start_time)s - ORDER BY query_start_time desc + ORDER BY query_start_time DESC LIMIT 100 ) - GROUP BY query_id""", + GROUP BY query_id + ORDER BY query_start_time DESC""", { "query": f"/* user_id:{request.user.pk} %", "start_time": (now() - relativedelta(minutes=10)).timestamp(),