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

[v1] Change integer types to error on overflow; give explicit data exception on div/mod by 0 #1715

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

alancai98
Copy link
Member

Relevant Issues

Description

  • Changes integer types to error on overflow
  • Changes integer types division and modulo by 0 to give an explicit data exception

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@alancai98 alancai98 requested a review from johnedquinn January 14, 2025 21:48
@alancai98 alancai98 self-assigned this Jan 14, 2025
Copy link

github-actions bot commented Jan 14, 2025

CROSS-ENGINE-REPORT ❌

BASE (LEGACY-V0.14.8) TARGET (EVAL-68547A4) +/-
% Passing 89.67% 93.20% 3.53% ✅
Passing 5287 5495 208 ✅
Failing 609 115 -494 ✅
Ignored 0 286 286 🔶
Total Tests 5896 5896 0 ✅

Testing Details

  • Base Commit: v0.14.8
  • Base Engine: LEGACY
  • Target Commit: 68547a4
  • Target Engine: EVAL

Result Details

  • ❌ REGRESSION DETECTED. See Now Failing/Ignored Tests. ❌
  • Passing in both: 2614
  • Failing in both: 32
  • Ignored in both: 0
  • PASSING in BASE but now FAILING in TARGET: 26
  • PASSING in BASE but now IGNORED in TARGET: 114
  • FAILING in BASE but now PASSING in TARGET: 165
  • IGNORED in BASE but now PASSING in TARGET: 0

Now FAILING Tests ❌

The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact.

Now IGNORED Tests ❌

The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact.

Now Passing Tests

165 test(s) were previously failing in BASE (LEGACY-V0.14.8) but now pass in TARGET (EVAL-68547A4). Before merging, confirm they are intended to pass.

The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact.

CROSS-COMMIT-REPORT ✅

BASE (EVAL-0868284) TARGET (EVAL-68547A4) +/-
% Passing 93.20% 93.20% 0.00% ✅
Passing 5495 5495 0 ✅
Failing 115 115 0 ✅
Ignored 286 286 0 ✅
Total Tests 5896 5896 0 ✅

Testing Details

  • Base Commit: 0868284
  • Base Engine: EVAL
  • Target Commit: 68547a4
  • Target Engine: EVAL

Result Details

  • Passing in both: 5495
  • Failing in both: 115
  • Ignored in both: 286
  • PASSING in BASE but now FAILING in TARGET: 0
  • PASSING in BASE but now IGNORED in TARGET: 0
  • FAILING in BASE but now PASSING in TARGET: 0
  • IGNORED in BASE but now PASSING in TARGET: 0

@alancai98 alancai98 force-pushed the int-overflow branch 2 times, most recently from 8d67e7b to afc865a Compare January 14, 2025 23:16
val arg0 = args[0].byte
val arg1 = args[1].byte
if (arg1 == 0.toByte()) {
throw DataException("Division by zero for TINYINT: $arg0 % $arg1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍 . SQL:1999 Section 6.17.

val arg1 = args[1].byte
val result = arg0 + arg1
if (result.byteOverflows()) {
throw DataException("Numeric value out of range for TINYINT: $arg0 + $arg1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw DataException("Numeric value out of range for TINYINT: $arg0 + $arg1")
throw DataException("Resulting value out of range for TINYINT: $arg0 + $arg1")

Non-blocking, but the use of "numeric" might be confusing due to there being a numeric data type.

@alancai98 alancai98 merged commit 36fbfeb into enable-some-randomized-tests Jan 14, 2025
12 checks passed
@@ -21,7 +21,7 @@ internal object FnDivide : DiadicArithmeticOperator("divide") {
if (arg1 == 0.toByte()) {
throw DataException("Division by zero for TINYINT: $arg0 / $arg1")
} else if (arg0 == Byte.MIN_VALUE && arg1.toInt() == -1) {
throw DataException("Overflow for TINYINT: $arg0 / $arg1")
throw DataException("Resulting value out of range for: $arg0 / $arg1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the following 3, you removed the type name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah my bad. I will fix in the target branch.

@alancai98 alancai98 deleted the int-overflow branch January 14, 2025 23:35
alancai98 added a commit that referenced this pull request Jan 15, 2025
…or on overflow

* [v1] Re-enable randomized tests

* [v1] Change integer types to error on overflow; give explicit data exception on div/mod by 0 (#1715)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v1] Behavior for arithmetic ops that overflow does not follow the SQL99 spec
2 participants