Test datasource: Returns always float values (#34986) (#35001)

(cherry picked from commit 51afde34bd)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2021-05-31 20:19:09 +03:00
committed by GitHub
co-authored by Sofia Papagiannaki
parent f70ffc30e7
commit 0b02a7e918
4 changed files with 21 additions and 40 deletions
+2 -21
View File
@@ -183,28 +183,9 @@ func csvValuesToField(parts []string) (*data.Field, error) {
return field, nil
}
// Try parsing values as numbers
// Try parsing values as floats
ok := false
field := data.NewFieldFromFieldType(data.FieldTypeNullableInt64, len(parts))
for idx, strVal := range parts {
if strVal == "null" || strVal == "" {
continue
}
val, err := strconv.ParseInt(strVal, 10, 64)
if err != nil {
ok = false
break
}
field.SetConcrete(idx, val)
ok = true
}
if ok {
return field, nil
}
// Maybe floats
field = data.NewFieldFromFieldType(data.FieldTypeNullableFloat64, len(parts))
field := data.NewFieldFromFieldType(data.FieldTypeNullableFloat64, len(parts))
for idx, strVal := range parts {
if strVal == "null" || strVal == "" {
continue