transform_plugin: pass encoded dataframes through (#20333)

This commit is contained in:
Kyle Brandt 2019-11-12 16:21:10 -05:00 committed by GitHub
parent 6959cf77ca
commit b8029dcd4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -239,18 +239,23 @@ func (s *grafanaAPI) QueryDatasource(ctx context.Context, req *pluginv2.QueryDat
if err != nil {
return nil, err
}
// Convert tsdb results (map) to plugin-model/datasource (slice) results
// Only error and Series responses mapped.
results := make([]*pluginv2.DatasourceQueryResult, len(tsdbRes.Results))
resIdx := 0
// Convert tsdb results (map) to plugin-model/datasource (slice) results.
// Only error, tsdb.Series, and encoded Dataframes responses are mapped.
results := make([]*pluginv2.DatasourceQueryResult, 0, len(tsdbRes.Results))
for refID, res := range tsdbRes.Results {
qr := &pluginv2.DatasourceQueryResult{
RefId: refID,
}
if res.Error != nil {
qr.Error = res.ErrorString
results[resIdx] = qr
resIdx++
results = append(results, qr)
continue
}
if res.Dataframes != nil {
qr.Dataframes = append(qr.Dataframes, res.Dataframes...)
results = append(results, qr)
continue
}
@ -266,9 +271,7 @@ func (s *grafanaAPI) QueryDatasource(ctx context.Context, req *pluginv2.QueryDat
}
}
qr.Dataframes = encodedFrames
results[resIdx] = qr
resIdx++
results = append(results, qr)
}
return &pluginv2.QueryDatasourceResponse{Results: results}, nil
}