-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support negative timestamps for the query engine #7212
Conversation
Need to fix a bunch of tests, but this seems to work in local testing. |
d4fb158
to
374f424
Compare
@@ -3630,7 +3630,7 @@ func TimeRange(expr Expr) (min, max time.Time, err error) { | |||
} | |||
|
|||
// TimeRangeAsEpochNano returns the minimum and maximum times, as epoch nano, specified by | |||
// and expression. If there is no lower bound, the start of the epoch is returned | |||
// and expression. If there is no lower bound, the minimum time is returned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You updated the comment here, but line 3642 still sets the min to time.Unix(0,0)
when the min time is unset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I went through a bunch of different revisions while doing this and I might have lost some things like this.
374f424
to
66c00f2
Compare
// ZeroTime is the Unix nanosecond timestamp for time.Time{}. | ||
const ZeroTime = int64(-6795364578871345152) | ||
// ZeroTime is the Unix nanosecond timestamp for no time. | ||
const ZeroTime = models.MinNanoTime - 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment for the arbitrary subtraction of two.
a921d0a
to
82d5a32
Compare
@joelegasse I tried my best to add documentation for why the arbitrary values for minimum and maximum times. |
Negative timestamps are now supported. We also now refuse two nanoseconds that are at the edge of the minimum time window. One of the nanoseconds we do not accept is because we need MinInt64 to be used for some internal comparisons in the TSM engine and it was causing an underflow when we subtracted one from the minimum time. The second is so we can have one minimum time that signifies the default minimum that nobody can write to (so we can implicitly rewrite the timestamp on aggregate queries) but still use the explicit timestamp if it is given to us by the user. We aren't able to tell the difference between if the user provided it or if it was implicit without those values being different. If the default minimum time is used with an aggregate query, we rewrite the time to be the epoch for backwards compatibility since we believe that's more important than supporting that extra nanosecond.
82d5a32
to
10029ca
Compare
Thanks for adding the comments. LGTM |
👍 |
Fixes #7194.