Skip to content
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

Merged
merged 1 commit into from
Aug 25, 2016

Conversation

jsternberg
Copy link
Contributor

@jsternberg jsternberg commented Aug 24, 2016

Fixes #7194.

@jsternberg
Copy link
Contributor Author

Need to fix a bunch of tests, but this seems to work in local testing.

@jsternberg jsternberg force-pushed the js-query-engine-negative-timestamps branch 3 times, most recently from d4fb158 to 374f424 Compare August 25, 2016 15:47
@@ -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
Copy link
Contributor

@joelegasse joelegasse Aug 25, 2016

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.

Copy link
Contributor Author

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.

@jsternberg jsternberg force-pushed the js-query-engine-negative-timestamps branch from 374f424 to 66c00f2 Compare August 25, 2016 16:03
// 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
Copy link
Contributor

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.

@jsternberg jsternberg force-pushed the js-query-engine-negative-timestamps branch 2 times, most recently from a921d0a to 82d5a32 Compare August 25, 2016 16:14
@jsternberg
Copy link
Contributor Author

@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.
@jsternberg jsternberg force-pushed the js-query-engine-negative-timestamps branch from 82d5a32 to 10029ca Compare August 25, 2016 17:52
@joelegasse
Copy link
Contributor

Thanks for adding the comments. LGTM

@benbjohnson
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants