Skip to content

Commit

Permalink
ts: better error message for bad query
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
andreimatei committed Aug 5, 2020
1 parent fb196f7 commit f38ebe1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/ts/timespan.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

package ts

import "fmt"
import (
"fmt"
"time"

"github.com/cockroachdb/cockroach/pkg/util/timeutil"
)

// QueryTimespan describes the time range information for a query - the start
// and end bounds of the query, along with the requested duration of individual
Expand Down Expand Up @@ -96,9 +101,12 @@ func (qt *QueryTimespan) adjustForCurrentTime(diskResolution Resolution) error {
// Do not allow queries in the future.
if qt.StartNanos > cutoff {
return fmt.Errorf(
"cannot query time series in the future (start time %d was greater than current clock %d",
qt.StartNanos,
qt.NowNanos,
"cannot query time series in the future (start time %s was greater than "+
"cutoff for current sample period %s); current time: %s; sample duration: %s",
timeutil.Unix(0, qt.StartNanos),
timeutil.Unix(0, cutoff),
timeutil.Unix(0, qt.NowNanos),
time.Duration(qt.SampleDurationNanos),
)
}
if qt.EndNanos > cutoff {
Expand Down

0 comments on commit f38ebe1

Please sign in to comment.