MaxGekk commented on a change in pull request #32940: URL: https://github.com/apache/spark/pull/32940#discussion_r657709476
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala ########## @@ -108,18 +108,22 @@ object IntervalUtils { def castStringToYMInterval( input: UTF8String, - // TODO(SPARK-35768): Take into account year-month interval fields in cast startField: Byte, endField: Byte): Int = { + + def truncatedMonth(month: String) : String = { + if (endField == YearMonthIntervalType.YEAR) "0" else month + } + input.trimAll().toString match { - case yearMonthRegex("-", year, month) => toYMInterval(year, month, -1) - case yearMonthRegex(_, year, month) => toYMInterval(year, month, 1) + case yearMonthRegex("-", year, month) => toYMInterval(year, truncatedMonth(month), -1) + case yearMonthRegex(_, year, month) => toYMInterval(year, truncatedMonth(month), 1) case yearMonthLiteralRegex(firstSign, secondSign, year, month) => Review comment: @AngersZhuuuu Could you open JIRA ticket for this, please. -- 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