cloud-fan commented on code in PR #37466:
URL: https://github.com/apache/spark/pull/37466#discussion_r944334882
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala:
##########
@@ -1283,6 +1283,20 @@ object IntervalUtils {
intToYearMonthInterval(vInt, startField, endField)
}
+ def decimalToYearMonthInterval(
+ d: Decimal, p: Int, s: Int, startField: Byte, endField: Byte): Int = {
+ try {
+ val months = if (endField == YEAR) d.toBigDecimal * MONTHS_PER_YEAR else
d.toBigDecimal
+ months.setScale(0, BigDecimal.RoundingMode.HALF_UP).toIntExact
Review Comment:
do we have a sql reference doc for cast? we should mention the rounding
behavior.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]