From cf041001bd8c34181e32e021be632c13ee8a4a99 Mon Sep 17 00:00:00 2001 From: jbguerraz <861556+jbguerraz@users.noreply.github.com> Date: Tue, 7 Mar 2023 10:59:01 +0000 Subject: [PATCH] check topn results size (#148) LGTM --- pkg/druid.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/druid.go b/pkg/druid.go index 0e15d91..521d2a9 100644 --- a/pkg/druid.go +++ b/pkg/druid.go @@ -554,7 +554,7 @@ func (ds *druidDatasource) executeQuery(queryRef string, q druidquerybuilder.Que case "topN": var tn []map[string]interface{} err := json.Unmarshal(result, &tn) - if err == nil && len(tn) > 0 { + if err == nil && len(tn) > 0 && len(tn[0]["result"].([]interface{})) > 0 { columns := []string{"timestamp"} for c := range tn[0]["result"].([]interface{})[0].(map[string]interface{}) { columns = append(columns, c)