SQL Datasources: Allow multiple string/labels columns with time series (#36485)

for #36370
This commit is contained in:
Kyle Brandt 2021-07-20 12:42:54 -04:00 committed by GitHub
parent aa3a46272f
commit 3ab9249f16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,7 +173,7 @@ func (e *dataPlugin) DataQuery(ctx context.Context, dsInfo *models.DataSource,
return result, nil return result, nil
} }
//nolint: staticcheck // plugins.DataQueryResult deprecated //nolint: staticcheck,gocyclo // plugins.DataQueryResult deprecated
func (e *dataPlugin) executeQuery(query plugins.DataSubQuery, wg *sync.WaitGroup, queryContext plugins.DataQuery, func (e *dataPlugin) executeQuery(query plugins.DataSubQuery, wg *sync.WaitGroup, queryContext plugins.DataQuery,
ch chan plugins.DataQueryResult) { ch chan plugins.DataQueryResult) {
defer wg.Done() defer wg.Done()
@ -292,6 +292,10 @@ func (e *dataPlugin) executeQuery(query plugins.DataSubQuery, wg *sync.WaitGroup
continue continue
} }
if t := frame.Fields[i].Type(); t == data.FieldTypeString || t == data.FieldTypeNullableString {
continue
}
var err error var err error
if frame, err = convertSQLValueColumnToFloat(frame, i); err != nil { if frame, err = convertSQLValueColumnToFloat(frame, i); err != nil {
errAppendDebug("convert value to float failed", err, interpolatedQuery) errAppendDebug("convert value to float failed", err, interpolatedQuery)
@ -892,7 +896,7 @@ func convertSQLValueColumnToFloat(frame *data.Frame, Index int) (*data.Frame, er
default: default:
convertUnknownToZero(frame.Fields[Index], newField) convertUnknownToZero(frame.Fields[Index], newField)
frame.Fields[Index] = newField frame.Fields[Index] = newField
return frame, fmt.Errorf("metricIndex %d type can't be converted to float", Index) return frame, fmt.Errorf("metricIndex %d type %s can't be converted to float", Index, valueType)
} }
frame.Fields[Index] = newField frame.Fields[Index] = newField