Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ case class MinutesOfTime(child: Expression)
Seq(child.dataType)
)

override def inputTypes: Seq[AbstractDataType] = Seq(TimeType())
override def inputTypes: Seq[AbstractDataType] =
Seq(TypeCollection(TimeType.MIN_PRECISION to TimeType.MAX_PRECISION map TimeType: _*))

override def children: Seq[Expression] = Seq(child)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,22 @@ class TimeExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
"docroot" -> SPARK_DOC_ROOT)
)

// test TIME-typed child should build MinutesOfTime
// test TIME-typed child should build MinutesOfTime for default precision value
val timeExpr = Literal(localTime(12, 58, 59), TimeType())
val builtExprForTime = MinuteExpressionBuilder.build("minute", Seq(timeExpr))
assert(builtExprForTime.isInstanceOf[MinutesOfTime])
assert(builtExprForTime.asInstanceOf[MinutesOfTime].child eq timeExpr)
assert(builtExprForTime.checkInputDataTypes().isSuccess)

// test TIME-typed child should build MinutesOfTime for all allowed custom precision values
(TimeType.MIN_PRECISION to TimeType.MICROS_PRECISION).foreach { precision =>
val timeExpr = Literal(localTime(12, 58, 59), TimeType(precision))
val builtExpr = MinuteExpressionBuilder.build("minute", Seq(timeExpr))

assert(builtExpr.isInstanceOf[MinutesOfTime])
assert(builtExpr.asInstanceOf[MinutesOfTime].child eq timeExpr)
assert(builtExpr.checkInputDataTypes().isSuccess)
}

// test non TIME-typed child should build Minute
val tsExpr = Literal("2009-07-30 12:58:59")
Expand Down