-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-30341][SQL] Overflow check for interval arithmetic operations #26995
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
Changes from 1 commit
829cfe7
516080c
67767c0
7293377
f100d88
ba44c5a
67645d4
7671d83
b679381
a8d29b6
c3a8531
ccb1fd5
d704c74
512570e
5651959
92e2668
aba10b2
e37caaf
988b51c
f80f0f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,8 +207,7 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper { | |
| withSQLConf(SQLConf.ANSI_ENABLED.key -> v) { | ||
| if (checkException) { | ||
| checkExceptionInExpression[ArithmeticException]( | ||
| MultiplyInterval(Literal(stringToInterval(interval)), Literal(num)), | ||
| "integer overflow") | ||
| MultiplyInterval(Literal(stringToInterval(interval)), Literal(num)), expected) | ||
|
||
| } else { | ||
| checkEvaluation(MultiplyInterval(Literal(stringToInterval(interval)), Literal(num)), | ||
| if (expected == null) null else stringToInterval(expected)) | ||
|
||
|
|
@@ -225,7 +224,7 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper { | |
| check("-100 years -1 millisecond", 0.5, "-50 years -500 microseconds") | ||
| check("2 months 4 seconds", -0.5, "-1 months -2 seconds") | ||
| check("1 month 2 microseconds", 1.5, "1 months 15 days 3 microseconds") | ||
| check("2 months", Int.MaxValue, null, checkException = true) | ||
| check("2 months", Int.MaxValue, "integer overflow", checkException = true) | ||
| } | ||
|
|
||
| test("divide") { | ||
|
|
@@ -238,8 +237,7 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper { | |
| withSQLConf(SQLConf.ANSI_ENABLED.key -> v) { | ||
| if (checkException) { | ||
| checkExceptionInExpression[ArithmeticException]( | ||
| DivideInterval(Literal(stringToInterval(interval)), Literal(num)), | ||
| "integer overflow") | ||
| DivideInterval(Literal(stringToInterval(interval)), Literal(num)), expected) | ||
|
||
| } else { | ||
| checkEvaluation(DivideInterval(Literal(stringToInterval(interval)), Literal(num)), | ||
| if (expected == null) null else stringToInterval(expected)) | ||
|
|
@@ -255,8 +253,8 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper { | |
| check("2 years -8 seconds", 0.5, "4 years -16 seconds") | ||
| check("-1 month 2 microseconds", -0.25, "4 months -8 microseconds") | ||
| check("1 month 3 microsecond", 1.5, "20 days 2 microseconds") | ||
| check("1 second", 0, null) | ||
| check(s"${Int.MaxValue} months", 0.9, null, checkException = true) | ||
| check("1 second", 0, "divide by zero", checkException = true) | ||
| check(s"${Int.MaxValue} months", 0.9, "integer overflow", checkException = true) | ||
| } | ||
|
|
||
| test("make interval") { | ||
|
|
||
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.
avg(interval)is also new in 3.0 right? We can also fail here if this is the SQL standard.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.
I checked pgsql, avg on empty table returns null. So this is corrected.