diff --git a/data/time_series.go b/data/time_series.go index 5cfb2857c..0156b3f79 100644 --- a/data/time_series.go +++ b/data/time_series.go @@ -308,7 +308,7 @@ func (p *longRowProcessor) process(longRowIdx int) error { } if currentTime.Before(p.lastTime) { - return fmt.Errorf("long series must be sorted ascending by time to be converted") + return ErrorSeriesUnsorted } sliceKey := make(tupleLabels, len(p.tsSchema.FactorIndices)) // factor columns idx:value tuples (used for lookup) @@ -386,7 +386,7 @@ func (p *longRowProcessor) process(longRowIdx int) error { func timeAt(idx int, longFrame *Frame, tsSchema TimeSeriesSchema) (time.Time, error) { // get time.Time regardless if pointer val, ok := longFrame.ConcreteAt(tsSchema.TimeIndex, idx) if !ok { - return time.Time{}, fmt.Errorf("can not convert to wide series, input has null time values") + return time.Time{}, ErrorNullTimeValues } return val.(time.Time), nil } @@ -420,7 +420,7 @@ func WideToLong(wideFrame *Frame) (*Frame, error) { if err != nil { return nil, err } else if wideLen == 0 { - return nil, fmt.Errorf("can not convert to long series, input fields have no rows") + return nil, ErrorInputFieldsWithoutRows } var uniqueValueNames []string // unique names of Fields that are value types diff --git a/data/time_series_errors.go b/data/time_series_errors.go new file mode 100644 index 000000000..e223ea93a --- /dev/null +++ b/data/time_series_errors.go @@ -0,0 +1,9 @@ +package data + +import "errors" + +var ( + ErrorNullTimeValues = errors.New("unable to process the data to wide series because input has null time values, make sure all time values are not null") + ErrorSeriesUnsorted = errors.New("unable to process the data because it is not sorted in ascending order by time, please updated your query to sort the data by time if possible") + ErrorInputFieldsWithoutRows = errors.New("can not convert to long series, input fields have no rows") +)