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

tree: add missing div-by-zero error for float div #37774

Merged
merged 1 commit into from May 24, 2019

Conversation

Projects
None yet
4 participants
@jordanlewis
Copy link
Member

commented May 23, 2019

Previously, dividing a float by 0 would return -Inf, instead of
returning a divide by 0 error as expected.

Release note (bug fix): dividing floats by zero now returns an error,
instead of -Inf.

@jordanlewis jordanlewis requested review from mjibson and rafiss May 23, 2019

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

@cockroach-teamcity

This comment has been minimized.

Copy link
Member

commented May 23, 2019

This change is Reviewable

@rafiss
Copy link
Collaborator

left a comment

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis and @mjibson)


pkg/sql/sem/tree/eval_test.go, line 255 at r1 (raw file):

		{`1 % 0`, `zero modulus`},
		{`1 / 0`, `division by zero`},
		{`1::float / 0::float`, `division by zero`},

why does the test go here instead of in testdata/eval/float_decimal_div? is it because it's an error?

@jordanlewis
Copy link
Member Author

left a comment

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @mjibson and @rafiss)


pkg/sql/sem/tree/eval_test.go, line 255 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

why does the test go here instead of in testdata/eval/float_decimal_div? is it because it's an error?

Yes, as far as I can tell, the datadriven package that we use for the eval tests here doesn't know how to expect errors yet. That would be a nice feature addition - for now, this other test has a good way of specifying expected errors.

@jordanlewis jordanlewis force-pushed the jordanlewis:fix-div-float-0 branch from 060e03d to 2f35aa4 May 23, 2019

@jordanlewis
Copy link
Member Author

left a comment

Also had to remove 2 older tests that expected float div-by-0 to return non-errors.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @mjibson and @rafiss)

@rafiss

rafiss approved these changes May 23, 2019

Copy link
Collaborator

left a comment

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @mjibson)

Show resolved Hide resolved pkg/sql/sem/tree/eval.go Outdated

@jordanlewis jordanlewis force-pushed the jordanlewis:fix-div-float-0 branch from 2f35aa4 to 0828313 May 23, 2019

tree: add missing div-by-zero error for float div
Previously, dividing a float by 0 would return -Inf, instead of
returning a divide by 0 error as expected.

Release note (bug fix): dividing floats by zero now returns an error,
instead of -Inf.

@jordanlewis jordanlewis force-pushed the jordanlewis:fix-div-float-0 branch from 0828313 to 9cdc5cf May 23, 2019

@jordanlewis

This comment has been minimized.

Copy link
Member Author

commented May 24, 2019

bors r+

TFTRs!

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

Merge #37774
37774: tree: add missing div-by-zero error for float div r=jordanlewis a=jordanlewis

Previously, dividing a float by 0 would return -Inf, instead of
returning a divide by 0 error as expected.

Release note (bug fix): dividing floats by zero now returns an error,
instead of -Inf.

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig

This comment has been minimized.

Copy link

commented May 24, 2019

Build succeeded

@craig craig bot merged commit 9cdc5cf into cockroachdb:master May 24, 2019

3 checks passed

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

@jordanlewis jordanlewis deleted the jordanlewis:fix-div-float-0 branch May 24, 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.