MaxGekk commented on code in PR #50296: URL: https://github.com/apache/spark/pull/50296#discussion_r2035301942
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala: ########## @@ -160,3 +161,75 @@ object TryToTimeExpressionBuilder extends ExpressionBuilder { } } } + +// scalastyle:off line.size.limit +@ExpressionDescription( + usage = """ + _FUNC_(time_expr) - Returns the minute component of the given time. + """, + examples = """ + Examples: + > SELECT _FUNC_(TIME'23:59:59.999999'); + 59 + """, + since = "4.1.0", + group = "datetime_funcs") +// scalastyle:on line.size.limit +case class MinutesOfTime(child: Expression) + extends RuntimeReplaceable + with ExpectsInputTypes { + + override def replacement: Expression = StaticInvoke( + classOf[DateTimeUtils.type], + IntegerType, + "getMinutesOfTime", + Seq(child), + Seq(child.dataType) + ) + + override def inputTypes: Seq[AbstractDataType] = Seq(TimeType()) Review Comment: @the-sakthi Could you open a follow up PR and allow any precision of the TIME type as you did for `second()` otherwise it fails now: ```sql spark-sql (default)> select minute(cast('12:30' as time(0))); [DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "minute(CAST(12:30 AS TIME(0)))" due to data type mismatch: The first parameter requires the "TIME(6)" type, however "CAST(12:30 AS TIME(0))" has the type "TIME(0)". SQLSTATE: 42K09; line 1 pos 7; ``` -- 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. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org 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