MaxGekk commented on code in PR #37466:
URL: https://github.com/apache/spark/pull/37466#discussion_r944369423


##########
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:
   We have the doc for cast: 
https://spark.apache.org/docs/latest/sql-ref-ansi-compliance.html#cast but it 
says that Spark doesn't support cast of intervals to numerics. Let me open a PR 
and document recent changes in casting of ANSI intervals.



-- 
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]

Reply via email to