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

sql: improve interval math for div and mul #37744

Merged
merged 1 commit into from May 23, 2019

Conversation

3 participants
@mjibson
Copy link
Member

commented May 22, 2019

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.

sql: improve interval math for div and mul
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.

@mjibson mjibson requested review from solongordon, rafiss and yuzefovich May 22, 2019

@mjibson mjibson requested a review from cockroachdb/sql-rest-prs as a code owner May 22, 2019

@cockroach-teamcity

This comment has been minimized.

Copy link
Member

commented May 22, 2019

This change is Reviewable

@solongordon
Copy link
Contributor

left a comment

:lgtm:

Reviewable status: :shipit: 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.

@mjibson

This comment has been minimized.

Copy link
Member Author

commented May 23, 2019

bors r+

craig bot pushed a commit that referenced this pull request May 23, 2019

Merge #37744
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.

Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
@craig

This comment has been minimized.

Copy link

commented May 23, 2019

Build failed

@mjibson

This comment has been minimized.

Copy link
Member Author

commented May 23, 2019

bors r+

craig bot pushed a commit that referenced this pull request May 23, 2019

Merge #37744
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.

Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
@craig

This comment has been minimized.

Copy link

commented May 23, 2019

Build failed

@mjibson

This comment has been minimized.

Copy link
Member Author

commented May 23, 2019

bors r+

craig bot pushed a commit that referenced this pull request May 23, 2019

Merge #37744 #37745
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>
@craig

This comment has been minimized.

Copy link

commented May 23, 2019

Build succeeded

@craig craig bot merged commit 567a5fe into cockroachdb:master May 23, 2019

3 checks passed

GitHub CI (Cockroach) TeamCity build finished
Details
bors Build succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@mjibson mjibson deleted the mjibson:interval-div branch May 23, 2019

@jordanlewis jordanlewis added this to 19.2.3 in SQL Execution Team May 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.