MaxGekk commented on a change in pull request #32281: URL: https://github.com/apache/spark/pull/32281#discussion_r618107919
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala ########## @@ -100,11 +100,15 @@ object IntervalUtils { */ def fromYearMonthString(input: String): CalendarInterval = { require(input != null, "Interval year-month string must be not null") - def toInterval(yearStr: String, monthStr: String): CalendarInterval = { + def toInterval(yearStr: String, monthStr: String, negative: Boolean): CalendarInterval = { Review comment: Let's re-use range check in toLongWithRange and simplify the code: ```scala def toInterval(yearStr: String, monthStr: String, sign: Int): CalendarInterval = { try { val years = toLongWithRange(YEAR, yearStr, 0, Integer.MAX_VALUE / MONTHS_PER_YEAR) val totalMonths = sign * (years * MONTHS_PER_YEAR + toLongWithRange(MONTH, monthStr, 0, 11)) new CalendarInterval(Math.toIntExact(totalMonths), 0, 0) } catch { case NonFatal(e) => throw new IllegalArgumentException( s"Error parsing interval year-month string: ${e.getMessage}", e) } } ``` -- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org