-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fix toMillis() should work for all presto timestamps #7506
Conversation
✅ Deploy Preview for meta-velox canceled.
|
This pull request was exported from Phabricator. Differential Revision: D51177715 |
…#7506) Summary: Presto timestamps are in the range TimeStamp::minMillis() to TimeStamp::maxMillis(). moreover minMillis has a comment: ``` // The minimum Timestamp that toMillis() method will not overflow. // Used to calculate the minimum value of the Presto timestamp. ``` Before this diff TimeStamp::minMillis().toMillis throws because the computation overflows. However in that case we multiply negative number then add positive number so the final result still fits in int64_t. It is important the toMillis does not throw when it should not, since it is used in functions like inPredicate() and other functions that do not expect it to throw for some values. Throwing will show up as incorrect results compared to presto. This diff fixes that . I wonder if we shall throw a runtime error in toMillis() instead. found while investigating facebookincubator#7161 Differential Revision: D51177715
b00cffb
to
36eac2b
Compare
This pull request was exported from Phabricator. Differential Revision: D51177715 |
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.
LGTM. Thank you for the fix!
(int64_t)(nanos_ / 1'000'000)); | ||
} catch (const std::exception& e) { | ||
__int128_t result = | ||
(__int128_t)seconds_ * 1'000 + (int64_t)(nanos_ / 1'000'000); |
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.
nit: Use int128_t
defined in Type.h.
…#7506) Summary: Presto timestamps are in the range TimeStamp::minMillis() to TimeStamp::maxMillis(). moreover minMillis has a comment: ``` // The minimum Timestamp that toMillis() method will not overflow. // Used to calculate the minimum value of the Presto timestamp. ``` Before this diff TimeStamp::minMillis().toMillis throws because the computation overflows. However in that case we multiply negative number then add positive number so the final result still fits in int64_t. It is important the toMillis does not throw when it should not, since it is used in functions like inPredicate() and other functions that do not expect it to throw for some values. Throwing will show up as incorrect results compared to presto. This diff fixes that . I wonder if we shall throw a runtime error in toMillis() instead. found while investigating facebookincubator#7161 Reviewed By: kagamiori Differential Revision: D51177715
36eac2b
to
253a78f
Compare
This pull request was exported from Phabricator. Differential Revision: D51177715 |
…#7506) Summary: Presto timestamps are in the range TimeStamp::minMillis() to TimeStamp::maxMillis(). moreover minMillis has a comment: ``` // The minimum Timestamp that toMillis() method will not overflow. // Used to calculate the minimum value of the Presto timestamp. ``` Before this diff TimeStamp::minMillis().toMillis throws because the computation overflows. However in that case we multiply negative number then add positive number so the final result still fits in int64_t. It is important the toMillis does not throw when it should not, since it is used in functions like inPredicate() and other functions that do not expect it to throw for some values. Throwing will show up as incorrect results compared to presto. This diff fixes that . I wonder if we shall throw a runtime error in toMillis() instead. found while investigating facebookincubator#7161 Reviewed By: kagamiori Differential Revision: D51177715
253a78f
to
69fc2cb
Compare
This pull request was exported from Phabricator. Differential Revision: D51177715 |
This pull request has been merged in 671e126. |
Conbench analyzed the 1 benchmark run on commit There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
Summary:
Presto timestamps are in the range TimeStamp::minMillis() to TimeStamp::maxMillis().
moreover minMillis has a comment:
Before this diff TimeStamp::minMillis().toMillis throws because the computation
overflows. However in that case we multiply negative number then add positive number
so the final result still fits in int64_t.
It is important the toMillis does not throw when it should not, since it is used in
functions like inPredicate() and other functions that do not expect it to throw
for some values. Throwing will show up as incorrect results compared to presto.
This diff fixes that .
I wonder if we shall throw a runtime error in toMillis() instead.
found while investigating #7161
Differential Revision: D51177715