Skip to content

Commit

Permalink
Fix missing values not being recognized as nil in timeseries queries
Browse files Browse the repository at this point in the history
  • Loading branch information
meln5674 committed Feb 3, 2023
1 parent 5c57a20 commit bf5b12d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (m *tableQueryModel) getValues(doc timestepDocument) ([]interface{}, error)
}

if values[ix] != nil && actualType != type_ {
return nil, fmt.Errorf("Type mismatch for field %s: expected %s, got %s (%#v)", name, type_, actualType, values[ix])
return nil, fmt.Errorf("Type mismatch for field %s: expected %s, got %s (%#v, %#v)", name, type_, actualType, value, values[ix])
}
}
return values, nil
Expand Down Expand Up @@ -414,12 +414,21 @@ func (m *timeseriesQueryModel) getValues(doc timestepDocument) ([]interface{}, e
name := field.Name
value := doc[name]
type_ := field.Type
value, ok := doc[name]
if !ok || value == nil {
if !type_.Nullable() {
return nil, fmt.Errorf("Field %s was null or absent, but is not nullable. If using schema inference, please increase the depth to the first document missing this field, or manually specify the schema", name)
}
valueValues[ix] = nil
continue
}

valueValues[ix], actualType, err = convertValue(value, type_.Nullable())
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("Failed to convert value for %s", name))
return nil, errors.Wrap(err, fmt.Sprintf("Failed to convert value for %s (%#v)", name, value))
}
if actualType != type_ {
return nil, fmt.Errorf("Type mismatch for field %s: expected %s, got %s", name, type_, actualType)
return nil, fmt.Errorf("Type mismatch for field %s: expected %s, got %s (%#v, %#v)", name, type_, actualType, value, valueValues[ix])
}
}

Expand Down

0 comments on commit bf5b12d

Please sign in to comment.