From 907b1eda1325434c7f41758a8628c4830591f394 Mon Sep 17 00:00:00 2001 From: Taras Priadka Date: Tue, 12 Jul 2022 13:25:47 -0700 Subject: [PATCH] Avoid conversion to wide if no rows since that throws errors. (#73) * Avoid conversion to wide if no rows since that throws errors. Signed-off-by: Taras Priadka --- pkg/pixie_queries.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/pixie_queries.go b/pkg/pixie_queries.go index 627496b..edec051 100644 --- a/pkg/pixie_queries.go +++ b/pkg/pixie_queries.go @@ -108,10 +108,14 @@ func (qp PixieQueryProcessor) queryScript( // Add the frames to the response. for _, tablePrinter := range tm.pxTablePrinterLst { - // If time series schema long && time_ column, convert to wide. Otherwise + // If time series schema long && time_ column && table not empty, convert to wide. Otherwise // proceed as normal. tsSchema := tablePrinter.frame.TimeSeriesSchema() - if tablePrinter.FormatGrafanaTimeFrame() && tsSchema.Type == data.TimeSeriesTypeLong { + numRows, err := tablePrinter.frame.RowLen() + if err != nil { + return nil, err + } + if numRows != 0 && tablePrinter.FormatGrafanaTimeFrame() && tsSchema.Type == data.TimeSeriesTypeLong { wideFrame, err := data.LongToWide(tablePrinter.frame, &data.FillMissing{Mode: data.FillModeNull}) if err != nil {