-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Reject FOR TIMESTAMP AS OF ... with future temporal value #12720
Conversation
Currently, based on #12719 |
@@ -4578,6 +4582,14 @@ private void validateVersionPointer(QualifiedObjectName tableName, QueryPeriod q | |||
if (pointer == null) { | |||
throw semanticException(INVALID_ARGUMENTS, queryPeriod, "Pointer value cannot be NULL"); | |||
} | |||
long pointerTimestampMillis = unpackMillisUtc((long) coerce(type, pointer, createTimestampWithTimeZoneType(3))); | |||
if (pointerTimestampMillis >= System.currentTimeMillis()) { |
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.
Compare with session start time.
This will make AS OF now()
queries fail deterministically. (Otherwise they will work sometimes, but not always)
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.
Addressed.
However, i decided to do the math with maximum precision. The AS OF now()
has millisecond precision and thus may be rounded to a milli that's sub-milli before the session start, thus may or may not be rejected.
The AS OF now(9)
(or higher precision) will deterministically be rejected, since session start time is measured with nano precision (Instant
).
4223999
to
6d74fb9
Compare
rebasing after #12719 merged. |
`StatementAnalyzer` sporadically needs to coerce a value to a desired type. Extract the existing code into a utility method.
6d74fb9
to
1946182
Compare
The time travel `FOR ... AS OF ...` syntax is meant to return consistent state of a table. The future state isn't known, so it cannot be consistently queried. Reject such queries on the engine side so that connectors do not have to deal with this complexity.
1946182
to
02a63bf
Compare
The time travel
FOR ... AS OF ...
syntax is meant to return consistentstate of a table. The future state isn't known, so it cannot be
consistently queried. Reject such queries on the engine side so that
connectors do not have to deal with this complexity.