yaooqinn commented on a change in pull request #26410:
[SPARK-29387][SQL][FOLLOWUP] Fix issues of the multiply and divide for intervals
URL: https://github.com/apache/spark/pull/26410#discussion_r343052720
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala
##########
@@ -137,7 +139,11 @@ abstract class IntervalNumOperation(
val iu = IntervalUtils.getClass.getName.stripSuffix("$")
s"""
try {
- ${ev.value} = $iu.$operationName($interval, $num);
+ if ($num != 0) {
+ ${ev.value} = $iu.$operationName($interval, $num);
+ } else {
+ ${ev.isNull} = true;
Review comment:
```scala
[info] IntervalExpressionsSuite:
[info] - millenniums (3 seconds, 280 milliseconds)
[info] - centuries (404 milliseconds)
[info] - decades (566 milliseconds)
[info] - years (680 milliseconds)
[info] - quarters (713 milliseconds)
[info] - months (1 second, 456 milliseconds)
[info] - days (270 milliseconds)
[info] - hours (243 milliseconds)
[info] - minutes (289 milliseconds)
[info] - seconds (317 milliseconds)
[info] - milliseconds (241 milliseconds)
[info] - microseconds (247 milliseconds)
[info] - epoch (163 milliseconds)
[info] - multiply (521 milliseconds)
[info] - divide (465 milliseconds)
[info] ScalaTest
[info] Run completed in 13 seconds, 609 milliseconds.
[info] Total number of tests run: 15
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 15, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
```
Add the tests with out this patch
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]