Skip to content

Commit

Permalink
Export errors for time series processing (#1134)
Browse files Browse the repository at this point in the history
* Export errors for time series processing

* Add more

* Update data/time_series_errors.go

* Fix lint

* Keep errors in same format

* Update

* Fix lint
  • Loading branch information
ivanahuckova authored Nov 6, 2024
1 parent 501b836 commit 2d900ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions data/time_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions data/time_series_errors.go
Original file line number Diff line number Diff line change
@@ -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")
)

0 comments on commit 2d900ed

Please sign in to comment.