cloud-fan commented on a change in pull request #26491: [SPARK-29870][SQL]
Unify the logic of multi-units interval string to CalendarInterval
URL: https://github.com/apache/spark/pull/26491#discussion_r346685302
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala
##########
@@ -598,26 +531,26 @@ object IntervalUtils {
} else if (s.matchAt(microsStr, i)) {
microseconds = Math.addExact(microseconds, currentValue)
i += microsStr.numBytes()
- } else return null
- case _ => return null
+ } else throwIAE(s"invalid unit '$nextWord'")
+ case _ => throwIAE(s"invalid unit '$nextWord'")
}
} catch {
- case _: ArithmeticException => return null
+ case e: ArithmeticException => throwIAE(e.getMessage, e)
}
state = UNIT_SUFFIX
case UNIT_SUFFIX =>
b match {
case 's' => state = UNIT_END
case ' ' => state = TRIM_BEFORE_SIGN
- case _ => return null
+ case _ => throwIAE(s"invalid unit suffix '$nextWord'")
Review comment:
`invalid unit '$nextWord'` is better if we can implement `nextword`
correctly. Or we should introduce "currentWord"
----------------------------------------------------------------
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]