robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r1999361950


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala:
##########
@@ -2556,6 +2556,118 @@ case class MakeDate(
     copy(year = newFirst, month = newSecond, day = newThird)
 }
 
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and 
second fields. If the configuration `spark.sql.ansi.enabled` is false, the 
function returns NULL on invalid inputs. Otherwise, it will throw an error 
instead.",
+  arguments = """
+    Arguments:
+      * hour - the hour to represent, from 0 to 23
+      * minute - the minute to represent, from 0 to 59
+      * second - the second to represent, from 0 to 59.999999
+  """,
+  examples = """
+    Examples:
+      > SELECT _FUNC_(6, 30, 45.887);
+       06:30:45.887
+      > SELECT _FUNC_(NULL, 30, 0);
+       NULL
+  """,
+  group = "datetime_funcs",
+  since = "4.1.0")
+// scalastyle:on line.size.limit
+case class MakeTime(
+                     hours: Expression,
+                     minutes: Expression,
+                     secAndMicros: Expression,
+                     failOnError: Boolean = SQLConf.get.ansiEnabled)
+  extends TernaryExpression with ImplicitCastInputTypes with 
SecAndNanosExtractor {
+  override def nullIntolerant: Boolean = true
+
+  def this(hours: Expression, minutes: Expression, secAndMicros: Expression) =
+    this(hours, minutes, secAndMicros, SQLConf.get.ansiEnabled)
+
+  override def first: Expression = hours
+  override def second: Expression = minutes
+  override def third: Expression = secAndMicros
+  override def inputTypes: Seq[AbstractDataType] = Seq(IntegerType, 
IntegerType, DecimalType(16, 6))
+  override def dataType: DataType = TimeType(TimeType.MAX_PRECISION)
+  override def nullable: Boolean = if (failOnError) 
children.exists(_.nullable) else true
+
+  override protected def nullSafeEval(hours: Any, minutes: Any, secAndMicros: 
Any): Any = {
+    val (secs, nanos) = toSecondsAndNanos(secAndMicros.asInstanceOf[Decimal])
+
+    try {
+      val lt = if (secs == 60) {
+        if (nanos == 0) {
+          // This case of sec = 60 and nanos = 0 is supported for 
compatibility with PostgreSQL

Review Comment:
   I removed this



-- 
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

Reply via email to