@@ -60,21 +60,23 @@ abstract class YearsFunctionBase[O] extends ScalarFunction[Int] with ReducibleFu
6060 val UTC : ZoneId = ZoneId .of(" UTC" )
6161 val EPOCH_LOCAL_DATE : LocalDate = Instant .EPOCH .atZone(UTC ).toLocalDate
6262
63- def invoke (ts : Long ): Int = {
63+ protected def doInvoke (ts : Long ): Long = {
6464 val localDate = DateTimeUtils .microsToInstant(ts).atZone(UTC ).toLocalDate
65- ChronoUnit .YEARS .between(EPOCH_LOCAL_DATE , localDate).toInt
65+ ChronoUnit .YEARS .between(EPOCH_LOCAL_DATE , localDate)
6666 }
6767}
6868
6969// This `years` function reduces `IntegerType` partition keys to `IntegerType` partition keys when
7070// partitions are reduced to partitions of a `days` function, which produces `DateType` keys.
7171object YearsFunction extends YearsFunctionBase [Int ] {
72+ def invoke (ts : Long ): Int = doInvoke(ts).toInt
7273 override def reducer (otherFunction : ReducibleFunction [_, _]): Reducer [Int , Int ] = null
7374}
7475
7576// This `years` function reduces `IntegerType` partition keys to `LongType` partition keys when
7677// partitions are reduced to partitions of a `days` function, which produces `DateType` keys.
7778object YearsFunctionWithToYearsReducerWithLongResult extends YearsFunctionBase [Long ] {
79+ def invoke (ts : Long ): Int = doInvoke(ts).toInt
7880 override def reducer (otherFunction : ReducibleFunction [_, _]): Reducer [Int , Long ] = {
7981 if (otherFunction == DaysFunctionWithToYearsReducerWithLongResult ) {
8082 YearsToYearsReducerWithLogResult ()
0 commit comments