datasource: testdata - add predicatable csv wave scenario (#18183)

This commit is contained in:
Kyle Brandt
2019-07-18 13:36:22 -04:00
committed by GitHub
parent e47546d529
commit 7cac393ddc
4 changed files with 157 additions and 40 deletions
+14
View File
@@ -42,6 +42,20 @@ func FloatFromPtr(f *float64) Float {
return NewFloat(*f, true)
}
// FloatFromString creates a new Float from string f.
// If the string is equal to the value of nullString then the Float will be null.
// An empty string f will return an error.
func FloatFromString(f string, nullString string) (Float, error) {
if f == nullString {
return FloatFromPtr(nil), nil
}
fV, err := strconv.ParseFloat(f, 64)
if err != nil {
return Float{}, err
}
return FloatFrom(fV), nil
}
// UnmarshalJSON implements json.Unmarshaler.
// It supports number and null input.
// 0 will not be considered a null Float.