yaooqinn 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_r346690471
##########
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:
or we change the logic of unit parsing we can extract the whole part like
`case _ if b>= 'A' $$ b<= 'z' => unit = s.substring(i,
s.numBytes()).subStringIndex(UTF8String.blankString(1), 1)` than do `unit` case
matching and error capture.
----------------------------------------------------------------
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]