From d97836f4076d0817af5dbf53d5cb7bd761d2a446 Mon Sep 17 00:00:00 2001 From: Kyle Brandt Date: Tue, 2 Sep 2025 14:49:04 -0400 Subject: [PATCH] SQL Expressions: Return error on malformed input (#110479) Fixup on a misleading error being returned due to a missing return statement in the code. Was returning the error "conversion succeeded but no frames" even though there was an error. --- pkg/expr/sql_command.go | 1 + pkg/expr/sql_command_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/pkg/expr/sql_command.go b/pkg/expr/sql_command.go index 1d67cf47cea..9f2042e7656 100644 --- a/pkg/expr/sql_command.go +++ b/pkg/expr/sql_command.go @@ -378,6 +378,7 @@ func handleSqlInput(ctx context.Context, tracer trace.Tracer, refID string, forR convertedFrames, err := ConvertToFullLong(dataFrames) if err != nil { result.Error = sql.MakeInputConvertError(err, refID, forRefIDs, dsType) + return result, true } if len(convertedFrames) == 0 { diff --git a/pkg/expr/sql_command_test.go b/pkg/expr/sql_command_test.go index bc4faa5ec0f..58b2e11fcb6 100644 --- a/pkg/expr/sql_command_test.go +++ b/pkg/expr/sql_command_test.go @@ -236,6 +236,17 @@ func TestHandleSqlInput(t *testing.T) { expectFrame: true, converted: true, }, + { + name: "supported type (timeseries-multi) but malformed returns error", + frames: data.Frames{ + data.NewFrame("", + data.NewField("time", nil, []string{"1"}), // string is not valid for time field + data.NewField("value", data.Labels{"host": "a"}, []*float64{fp(2)}), + ).SetMeta(&data.FrameMeta{Type: data.FrameTypeTimeSeriesMulti}), + }, + expectErr: "missing time field", + converted: true, + }, } for _, tc := range tests {