Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that we are dereferencing elements that exists #35

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions pkg/rockset.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ func (d *Datasource) query(ctx context.Context, rs *rockset.RockClient, query ba
log.DefaultLogger.Error("query error", "error", errMessage)
return backend.ErrDataResponse(statusCode, errMessage)
}
log.DefaultLogger.Info("query response", "elapsedTime", qr.Stats.ElapsedTimeMs, "results", len(qr.Results))
log.DefaultLogger.Info("query response", "elapsedTime", qr.Stats.ElapsedTimeMs, "# of results", len(qr.Results))

if len(qr.Results) == 0 {
errMsg := "Query returned no lines"
return backend.ErrDataResponse(backend.StatusValidationFailed, errMsg)
}

labelValues, err := generateLabelValues(qm.QueryLabelColumn, qr.Results)
if err != nil {
Expand All @@ -171,14 +176,19 @@ func (d *Datasource) query(ctx context.Context, rs *rockset.RockClient, query ba
}

// only add the frame if it contains any useful data
if frame.Fields[1].Len() > 0 {
if len(frame.Fields) > 1 && frame.Fields[1].Len() > 0 {
response.Frames = append(response.Frames, frame)
}
}
}

if len(response.Frames) == 0 {
errMsg := fmt.Sprintf("no usable columns found in query response: %s", err.Error())
var errMsg string
if err == nil {
errMsg = "no usable columns found in query response"
} else {
errMsg = fmt.Sprintf("no usable columns found in query response: %s", err.Error())
}
return backend.ErrDataResponse(backend.StatusValidationFailed, errMsg)
}

Expand Down