-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: improve interval math for div and mul #37744
Conversation
In #37582 we added correct `interval * float` semantics. Here we extend that to float division. In addition, change int division to be a wrapper around float division so that remainders are correctly handled. Int multiply has no need to change since it's lossless. Release note (sql change): Correct interval math when multiplying or dividing by floats or ints.
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mjibson, @rafiss, @solongordon, and @yuzefovich)
pkg/sql/logictest/testdata/logic_test/datetime, line 1380 at r1 (raw file):
1 day 12:00:00 2 days 12:00:00 2 days 4 days 05:36:31.701948 05:40:07.68 1 mon 15 days 2 mons 15 days 2 mons 4 mons 7 days 00:15:51.058425 7 days 02:03:50.4 1 mon 2 days 04:00:00 16 days 02:00:00 2 mons 4 days 08:00:00 16 days 02:00:00 2 mons 4 days 08:00:00 4 mons 15 days 28:24:59.745978 7 days 14:20:47.04
Weird how it's 4 mons 15 days 28:24:59.745978
rather than 4 mons 16 days 04:24:59.745978
, but it matches Postgres so great.
bors r+ |
Build failed |
bors r+ |
Build failed |
bors r+ |
37744: sql: improve interval math for div and mul r=mjibson a=mjibson In #37582 we added correct `interval * float` semantics. Here we extend that to float division. In addition, change int division to be a wrapper around float division so that remainders are correctly handled. Int multiply has no need to change since it's lossless. Release note (sql change): Correct interval math when multiplying or dividing by floats or ints. 37745: col{data,serde}: various fixes related to TestArrowBatchConverterRandom r=solongordon a=asubiotto See individual commits for details Fixes #37458 Fixes #37692 Co-authored-by: Matt Jibson <matt.jibson@gmail.com> Co-authored-by: Alfonso Subiotto Marqués <alfonso@cockroachlabs.com>
Build succeeded |
In #37582 we added correct
interval * float
semantics. Here we extend that tofloat division.
In addition, change int division to be a wrapper around float division so that
remainders are correctly handled. Int multiply has no need to change since it's
lossless.
Release note (sql change): Correct interval math when multiplying or dividing
by floats or ints.