Skip to content

Commit 3eb6436

Browse files
committed
fix test failures due to missing invoke
1 parent 2e5d819 commit 3eb6436

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

sql/core/src/test/scala/org/apache/spark/sql/connector/catalog/functions/transformFunctions.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
7171
object 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.
7778
object 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

Comments
 (0)