You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "robreeves (via GitHub)" <gi...@apache.org> on 2025/03/13 17:03:05 UTC

[PR] [SPARK-51414][SQL] Add the make_time() function [spark]

robreeves opened a new pull request, #50269:
URL: https://github.com/apache/spark/pull/50269

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
   
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2001809416


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala:
##########
@@ -2556,6 +2556,91 @@ 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.",

Review Comment:
   I updated this, but needed to create a new error code `DATETIME_FIELD_OUT_OF_BOUNDS_ANSI_ONLY` since the existing one suggests disabling ansi behavior.
   
   I decided to create the new code to minimize changes and the change in a public facing error code could be considered a breaking changed. Absent those concerns I would have liked to make the new error code `DATETIME_FIELD_OUT_OF_BOUNDS` and rename the existing one to `DATETIME_FIELD_OUT_OF_BOUNDS_ANSI_OPTIONAL`. 



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2787650709

   There is one test failure in the PR build, but I don't think it is related to this change.
   ```
   SPARK-47148: AQE should avoid to submit shuffle job on cancellation *** FAILED *** (6 seconds, 100 milliseconds)
   ```


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2026485234


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -160,3 +162,76 @@ object TryToTimeExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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)
+  extends TernaryExpression with ImplicitCastInputTypes with SecAndNanosExtractor {
+  override def nullIntolerant: Boolean = true
+
+  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 = children.exists(_.nullable)
+
+  override protected def nullSafeEval(hours: Any, minutes: Any, secAndMicros: Any): Any = {
+    val (secs, nanos) = toSecondsAndNanos(secAndMicros.asInstanceOf[Decimal])
+
+    try {
+      val lt = LocalTime.of(
+        hours.asInstanceOf[Int],
+        minutes.asInstanceOf[Int],
+        secs,
+        nanos)
+      localTimeToMicros(lt)
+    } catch {
+      case e: DateTimeException =>
+        throw QueryExecutionErrors.ansiDateTimeArgumentOutOfRangeWithoutSuggestion(e)
+    }
+  }
+
+  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {

Review Comment:
   Yep.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2033738910


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -290,3 +290,45 @@ object HourExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable with ExpectsInputTypes {
+
+  override def inputTypes: Seq[AbstractDataType] = Seq(IntegerType, IntegerType, DecimalType(16, 6))
+  override def children: Seq[Expression] = Seq(hours, minutes, secsAndMicros)
+  override def dataType: DataType = TimeType(TimeType.MAX_PRECISION)
+  override def prettyName: String = "make_time"
+
+  override def replacement: Expression = StaticInvoke(
+    classOf[DateTimeUtils.type],
+    LongType,

Review Comment:
   Fixed:
   ```scala
   scala> spark.sql("select typeof(make_time(6, 30, 45.887))").first
   val res1: org.apache.spark.sql.Row = [time(6)]
   ```



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2745050759

   @robreeves Could you regenerate golden files:
   ```
   [info] - date.sql *** FAILED *** (1 second, 162 milliseconds)
   [info]   date.sql
   [info]   Expected "..._FIELD_OUT_OF_BOUNDS[]",
   [info]     "sqlState" : "2...", but got "..._FIELD_OUT_OF_BOUNDS[.WITH_SUGGESTION]",
   [info]     "sqlState" : "2..." Result did not match for query #4
   ```


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2023220047


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -160,3 +162,76 @@ object TryToTimeExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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)
+  extends TernaryExpression with ImplicitCastInputTypes with SecAndNanosExtractor {
+  override def nullIntolerant: Boolean = true
+
+  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 = children.exists(_.nullable)
+
+  override protected def nullSafeEval(hours: Any, minutes: Any, secAndMicros: Any): Any = {
+    val (secs, nanos) = toSecondsAndNanos(secAndMicros.asInstanceOf[Decimal])
+
+    try {
+      val lt = LocalTime.of(
+        hours.asInstanceOf[Int],
+        minutes.asInstanceOf[Int],
+        secs,
+        nanos)
+      localTimeToMicros(lt)
+    } catch {
+      case e: DateTimeException =>
+        throw QueryExecutionErrors.ansiDateTimeArgumentOutOfRangeWithoutSuggestion(e)
+    }
+  }
+
+  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {

Review Comment:
   @MaxGekk sorry for the delay on this. I should have this done in the next couple of days. You mean to do it like [this](https://github.com/robreeves/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala#L182) example, right?



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2002870806


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -1188,6 +1188,12 @@
     ],
     "sqlState" : "22023"
   },
+  "DATETIME_FIELD_OUT_OF_BOUNDS_ANSI_ONLY" : {

Review Comment:
   Could you create two sub-classes of `DATETIME_FIELD_OUT_OF_BOUNDS` like:
   ```
       "subClass" : {
         "WITHOUT_SUGGESTION" : {
           "message" : [
             ""
           ]
         },
         "WITH_SUGGESTION" : {
           "message" : [
             "If necessary set <ansiConfig> to \"false\" to bypass this error."
           ]
         }
       },
   ```
   see for instance:
   https://github.com/apache/spark/blob/35e0e08acab1539f9984d1dbabe691fee07fbd98/common/utils/src/main/resources/error/error-conditions.json#L5530
   https://github.com/apache/spark/blob/35e0e08acab1539f9984d1dbabe691fee07fbd98/common/utils/src/main/resources/error/error-conditions.json#L4246
   https://github.com/apache/spark/blob/35e0e08acab1539f9984d1dbabe691fee07fbd98/common/utils/src/main/resources/error/error-conditions.json#L5318



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2007998431


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -1188,6 +1188,12 @@
     ],
     "sqlState" : "22023"
   },
+  "DATETIME_FIELD_OUT_OF_BOUNDS_ANSI_ONLY" : {

Review Comment:
   Nice, I didn't know this existed. Updated.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2033737776


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -290,3 +290,45 @@ object HourExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable with ExpectsInputTypes {

Review Comment:
   Fixed:
   ```scala
   scala> spark.sql("select make_time(6, 30, 45.887)").first
   val res0: org.apache.spark.sql.Row = [06:30:45.887]
   ```



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2816594720

   @robreeves There is a list of contributors of Apache Spark in JIRA. You wasn't in the list for some reasons (I guess, a previous committer forgot to add you). Now you are in the list.


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2811796060

   +1, LGTM. Merging to master.
   Thank you, @robreeves.


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2788661153

   > There is one test failure in the PR build, but I don't think it is related to this change.
   
   It seems it is not related. @robreeves Could you update PR's description, and adjust it to the current implementation, please:
   ```
   This also has logic to align with Postgres when 60 seconds is specified. In this case it will add one minute and set seconds to 0. I added this because I saw that MakeTimestamp does this. I verified the make_time function in postgres has this behavior too.
   ```


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2036458898


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -290,3 +290,47 @@ object HourExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable
+    with ImplicitCastInputTypes
+    with ExpectsInputTypes {
+
+  override def inputTypes: Seq[AbstractDataType] = Seq(IntegerType, IntegerType, DecimalType(16, 6))
+  override def children: Seq[Expression] = Seq(hours, minutes, secsAndMicros)
+  override def dataType: DataType = TimeType(TimeType.MAX_PRECISION)

Review Comment:
   I deleted the override



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk closed pull request #50269: [SPARK-51414][SQL] Add the make_time() function
URL: https://github.com/apache/spark/pull/50269


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2814121837

   @MaxGekk thanks for the reviews! This wasn't my first contribution to Spark, but was my first change in the SQL layer.


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2035655031


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -763,4 +763,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
       throw QueryExecutionErrors.invalidDatetimeUnitError("TIMESTAMPDIFF", unit)
     }
   }
+
+  /**
+   * Converts separate time fields in a long that represents microseconds since the start of
+   * the day
+   * @param hours the hour, from 0 to 23
+   * @param minutes the minute, from 0 to 59
+   * @param secsAndMicros the second, from 0 to 59.999999
+   * @return Time time represented as microseconds since the start of the day
+   */
+  def timeToMicros(hours: Int, minutes: Int, secsAndMicros: Decimal): Long = {
+    assert(secsAndMicros.scale == 6,
+      s"Seconds fraction must have 6 digits for microseconds but got ${secsAndMicros.scale}")
+    val unscaledSecFrac = secsAndMicros.toUnscaledLong
+    val totalMicros = unscaledSecFrac.toInt // 8 digits cannot overflow Int
+    val fullSecs = Math.floorDiv(totalMicros, MICROS_PER_SECOND.toInt)
+    val nanos = Math.floorMod(totalMicros, MICROS_PER_SECOND.toInt) * NANOS_PER_MICROS.toInt

Review Comment:
   I would prefer to avoid unrelated changes in this PR. Let's properly implement `make_time()` in the PR, and refactor `make_timestamp` code later in a separate PR.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2001535420


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala:
##########
@@ -2150,4 +2150,66 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
       condition = "INTERNAL_ERROR",
       parameters = Map("message" -> "Cannot evaluate expression: localtimestamp(Some(UTC))"))
   }
+
+  test("creating values of TimeType via make_time") {
+    Seq(true, false).foreach { ansi =>
+      withSQLConf(SQLConf.ANSI_ENABLED.key -> ansi.toString) {
+        // basic case
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(2, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          LocalTime.of(13, 2, 23, 500000000))
+
+        // null cases
+        checkEvaluation(
+          MakeTime(Literal.create(null, IntegerType), Literal(18),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(null, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(MakeTime(Literal(13), Literal(18),
+          Literal.create(null, DecimalType(16, 6))), null)
+      }
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
+      // Invalid times return null
+      checkEvaluation(
+        MakeTime(Literal(Int.MaxValue), Literal(18),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(
+        MakeTime(Literal(13), Literal(Int.MinValue),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(MakeTime(Literal(13), Literal(18),
+        Literal(Decimal(BigDecimal(60.1), 16, 6))), null)
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      val errorCode = "DATETIME_FIELD_OUT_OF_BOUNDS"
+      val baseErrorParams = Map("ansiConfig" -> "\"spark.sql.ansi.enabled\"")
+      
+      checkErrorInExpression[SparkDateTimeException](

Review Comment:
   I don't understand the suggestion. This implementation does use `checkErrorInExpression` and checks the error condition and message params.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2003516395


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala:
##########
@@ -2556,6 +2556,79 @@ 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. For invalid inputs it will throw an error.",
+  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(

Review Comment:
   Please, move the expression to `timeExpressions.scala`. It contains the `ToTime` expression already.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2039329478


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -349,3 +349,49 @@ object SecondExpressionBuilder extends ExpressionBuilder {
   }
 }
 
+

Review Comment:
   nit: unnecessary blank line. Please, remove it.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -291,14 +291,22 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
 
   def ansiDateTimeArgumentOutOfRange(e: Exception): SparkDateTimeException = {
     new SparkDateTimeException(
-      errorClass = "DATETIME_FIELD_OUT_OF_BOUNDS",
+      errorClass = "DATETIME_FIELD_OUT_OF_BOUNDS.WITH_SUGGESTION",
       messageParameters = Map(
         "rangeMessage" -> e.getMessage,
         "ansiConfig" -> toSQLConf(SQLConf.ANSI_ENABLED.key)),
       context = Array.empty,
       summary = "")
   }
 
+  def ansiDateTimeArgumentOutOfRangeWithoutSuggestion(e: Throwable): SparkDateTimeException = {
+    new SparkDateTimeException(

Review Comment:
   Please, set `e` to `cause` in `SparkDateTimeException`. It might be helpful in debugging at user's side.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -349,3 +349,49 @@ object SecondExpressionBuilder extends ExpressionBuilder {
   }
 }
 
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable
+    with ImplicitCastInputTypes
+    with ExpectsInputTypes {
+
+  // Accept `sec` as DecimalType to avoid loosing precision of microseconds while converting

Review Comment:
   Thank you for the comment.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2035627896


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -763,4 +763,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
       throw QueryExecutionErrors.invalidDatetimeUnitError("TIMESTAMPDIFF", unit)
     }
   }
+
+  /**
+   * Converts separate time fields in a long that represents microseconds since the start of
+   * the day
+   * @param hours the hour, from 0 to 23
+   * @param minutes the minute, from 0 to 59
+   * @param secsAndMicros the second, from 0 to 59.999999
+   * @return Time time represented as microseconds since the start of the day
+   */
+  def timeToMicros(hours: Int, minutes: Int, secsAndMicros: Decimal): Long = {
+    assert(secsAndMicros.scale == 6,
+      s"Seconds fraction must have 6 digits for microseconds but got ${secsAndMicros.scale}")
+    val unscaledSecFrac = secsAndMicros.toUnscaledLong
+    val totalMicros = unscaledSecFrac.toInt // 8 digits cannot overflow Int

Review Comment:
   This is existing logic that I chose to make consistent with `MakeTimestamp` [here](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala#L2833). I agree it seems like it should be 6 at max. I can refactor it so both classes share it like I originally had when MakeTime was in datetimeExpressions if you prefer to couple them together.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2035631465


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -763,4 +763,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
       throw QueryExecutionErrors.invalidDatetimeUnitError("TIMESTAMPDIFF", unit)
     }
   }
+
+  /**
+   * Converts separate time fields in a long that represents microseconds since the start of
+   * the day
+   * @param hours the hour, from 0 to 23
+   * @param minutes the minute, from 0 to 59
+   * @param secsAndMicros the second, from 0 to 59.999999
+   * @return Time time represented as microseconds since the start of the day
+   */
+  def timeToMicros(hours: Int, minutes: Int, secsAndMicros: Decimal): Long = {
+    assert(secsAndMicros.scale == 6,
+      s"Seconds fraction must have 6 digits for microseconds but got ${secsAndMicros.scale}")
+    val unscaledSecFrac = secsAndMicros.toUnscaledLong
+    val totalMicros = unscaledSecFrac.toInt // 8 digits cannot overflow Int
+    val fullSecs = Math.floorDiv(totalMicros, MICROS_PER_SECOND.toInt)
+    val nanos = Math.floorMod(totalMicros, MICROS_PER_SECOND.toInt) * NANOS_PER_MICROS.toInt

Review Comment:
   This is existing logic [here](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala#L2830) that I chose to be consistent with. Do you want me to change that code too?



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2000708917


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala:
##########
@@ -2556,6 +2556,91 @@ 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.",

Review Comment:
   I believe we don't need the non-ANSI behavior in new functions/expression. Let's follow the ANSI SQL standard, and just raise an error.
   
   If users need NULLs on invalid inputs, they can invoke `try_make_time` which we introduce later.



##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala:
##########
@@ -2150,4 +2150,66 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
       condition = "INTERNAL_ERROR",
       parameters = Map("message" -> "Cannot evaluate expression: localtimestamp(Some(UTC))"))
   }
+
+  test("creating values of TimeType via make_time") {
+    Seq(true, false).foreach { ansi =>
+      withSQLConf(SQLConf.ANSI_ENABLED.key -> ansi.toString) {
+        // basic case
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(2, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          LocalTime.of(13, 2, 23, 500000000))
+
+        // null cases
+        checkEvaluation(
+          MakeTime(Literal.create(null, IntegerType), Literal(18),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(null, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(MakeTime(Literal(13), Literal(18),
+          Literal.create(null, DecimalType(16, 6))), null)
+      }
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
+      // Invalid times return null
+      checkEvaluation(
+        MakeTime(Literal(Int.MaxValue), Literal(18),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(
+        MakeTime(Literal(13), Literal(Int.MinValue),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(MakeTime(Literal(13), Literal(18),
+        Literal(Decimal(BigDecimal(60.1), 16, 6))), null)
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      val errorCode = "DATETIME_FIELD_OUT_OF_BOUNDS"
+      val baseErrorParams = Map("ansiConfig" -> "\"spark.sql.ansi.enabled\"")
+      
+      checkErrorInExpression[SparkDateTimeException](

Review Comment:
   Could you use `checkErrorInExpression` which checks the error condition and error message parameters.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2032600855


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -290,3 +290,45 @@ object HourExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable with ExpectsInputTypes {

Review Comment:
   How about to use the implicit cast otherwise users have to cast seconds to the expected decimal:
   ```sql
   spark-sql (default)> select make_time(6, 30, 45.887);
   [DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "make_time(6, 30, 45.887)" due to data type mismatch: The third parameter requires the "DECIMAL(16,6)" type, however "45.887" has the type "DECIMAL(5,3)". SQLSTATE: 42K09; line 1 pos 7;
   'Project [unresolvedalias(make_time(6, 30, 45.887))]
   +- OneRowRelation
   
   spark-sql (default)> select make_time(6, 30, cast(45.887 as decimal(16,6)));
   23445887000
   ```



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2795858475

   @MaxGekk this is ready for review again


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r1999366342


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

Review Comment:
   Updated



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2032604831


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -290,3 +290,45 @@ object HourExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable with ExpectsInputTypes {
+
+  override def inputTypes: Seq[AbstractDataType] = Seq(IntegerType, IntegerType, DecimalType(16, 6))
+  override def children: Seq[Expression] = Seq(hours, minutes, secsAndMicros)
+  override def dataType: DataType = TimeType(TimeType.MAX_PRECISION)
+  override def prettyName: String = "make_time"
+
+  override def replacement: Expression = StaticInvoke(
+    classOf[DateTimeUtils.type],
+    LongType,

Review Comment:
   The return type should `TimeType`, see for example
   ```sql
   spark-sql (default)> select typeof(make_time(6, 30, cast(45.887 as decimal(16,6))));
   bigint
   spark-sql (default)> select typeof(to_time('6:30:45.887'));
   time(6)
   ```



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2767146885

   @robreeves Could you regenerate expected outputs, please:
   ```
   [info] ExpressionsSchemaSuite:
   [info] - Check schemas for expression examples *** FAILED *** (533 milliseconds)
   [info]   478 did not equal 479 Expected 478 blocks in result file but got 479. Try regenerating the result files. (ExpressionsSchemaSuite.scala:171)
   ```
   for instance:
   ```
   $ SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "test:testOnly *ExpressionsSchemaSuite"
   ```


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r1996630578


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala:
##########
@@ -2150,4 +2150,71 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
       condition = "INTERNAL_ERROR",
       parameters = Map("message" -> "Cannot evaluate expression: localtimestamp(Some(UTC))"))
   }
+
+  test("creating values of TimeType via make_time") {
+    Seq(true, false).foreach { ansi =>
+      withSQLConf(SQLConf.ANSI_ENABLED.key -> ansi.toString) {
+        // basic case
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(2, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          LocalTime.of(13, 2, 23, 500000000))
+
+        // Postgres compatibility
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(2, IntegerType),
+            Literal(Decimal(BigDecimal(60), 16, 6))),
+          LocalTime.of(13, 3, 0, 0))
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(59, IntegerType),
+            Literal(Decimal(BigDecimal(60), 16, 6))),
+          LocalTime.of(14, 0, 0, 0))
+
+        // null cases
+        checkEvaluation(
+          MakeTime(Literal.create(null, IntegerType), Literal(18),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(null, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(MakeTime(Literal(13), Literal(18),
+          Literal.create(null, DecimalType(16, 6))), null)
+      }
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
+      // Invalid times return null
+      checkEvaluation(
+        MakeTime(Literal(Int.MaxValue), Literal(18),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(
+        MakeTime(Literal(13), Literal(Int.MinValue),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(MakeTime(Literal(13), Literal(18),
+        Literal(Decimal(BigDecimal(65.1), 16, 6))), null)
+      checkEvaluation(MakeTime(Literal(13), Literal(18),
+        Literal(Decimal(BigDecimal(60.1), 16, 6))), null)
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      checkExceptionInExpression[DateTimeException](
+        MakeTime(Literal(25), Literal(2), Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        "Invalid value for HourOfDay")
+      checkExceptionInExpression[DateTimeException](
+        MakeTime(Literal(23), Literal(-1), Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        "Invalid value for MinuteOfHour")
+      checkExceptionInExpression[DateTimeException](
+        MakeTime(Literal(23), Literal(12), Literal(Decimal(BigDecimal(100.5), 16, 6))),
+        "Invalid value for SecondOfMinute")
+
+      // Invalid Postgres compatability case where seconds=60 and has a fractional second
+      checkExceptionInExpression[DateTimeException](
+        MakeTime(Literal(23), Literal(12), Literal(Decimal(BigDecimal(60.5), 16, 6))),
+        "[INVALID_FRACTION_OF_SECOND] Valid range for seconds is [0, 60]")

Review Comment:
   Could you use `checkErrorInExpression`, please. It would be nice to avoid dependencies of error messages in tests. In this way, it will be possible to improve error messages without touching/repackaging spark distro.



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

Review Comment:
   Fix indentation, please, see https://github.com/databricks/scala-style-guide?tab=readme-ov-file#spacing-and-indentation



##########
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 believe we don't need this legacy feature of PostgreSQL. Let's just strictly follow the SQL standard, and support seconds in the range from 0 to 59.999999.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2726313834

   This test failure will be fixed by https://github.com/apache/spark/pull/50282
   ```
   [info] - check outputs of expression examples *** FAILED *** (9 seconds, 272 milliseconds)
   ...
   [info]   Cause: scala.MatchError: (06:30:45.887,TimeType(6)) (of class scala.Tuple2)
   [info]   at org.apache.spark.sql.execution.HiveResult$.toHiveString(HiveResult.scala:111)
   ```


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2726212080

   These test failures don't look related to my changes. I'm rerunning them.


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2001596554


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala:
##########
@@ -2150,4 +2150,66 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
       condition = "INTERNAL_ERROR",
       parameters = Map("message" -> "Cannot evaluate expression: localtimestamp(Some(UTC))"))
   }
+
+  test("creating values of TimeType via make_time") {
+    Seq(true, false).foreach { ansi =>
+      withSQLConf(SQLConf.ANSI_ENABLED.key -> ansi.toString) {
+        // basic case
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(2, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          LocalTime.of(13, 2, 23, 500000000))
+
+        // null cases
+        checkEvaluation(
+          MakeTime(Literal.create(null, IntegerType), Literal(18),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(null, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(MakeTime(Literal(13), Literal(18),
+          Literal.create(null, DecimalType(16, 6))), null)
+      }
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
+      // Invalid times return null
+      checkEvaluation(
+        MakeTime(Literal(Int.MaxValue), Literal(18),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(
+        MakeTime(Literal(13), Literal(Int.MinValue),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(MakeTime(Literal(13), Literal(18),
+        Literal(Decimal(BigDecimal(60.1), 16, 6))), null)
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      val errorCode = "DATETIME_FIELD_OUT_OF_BOUNDS"
+      val baseErrorParams = Map("ansiConfig" -> "\"spark.sql.ansi.enabled\"")
+      
+      checkErrorInExpression[SparkDateTimeException](

Review Comment:
   sorry, I looked at outdated code. Please, ignore the comment.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2008688974


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -160,3 +162,76 @@ object TryToTimeExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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)
+  extends TernaryExpression with ImplicitCastInputTypes with SecAndNanosExtractor {
+  override def nullIntolerant: Boolean = true
+
+  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 = children.exists(_.nullable)
+
+  override protected def nullSafeEval(hours: Any, minutes: Any, secAndMicros: Any): Any = {
+    val (secs, nanos) = toSecondsAndNanos(secAndMicros.asInstanceOf[Decimal])
+
+    try {
+      val lt = LocalTime.of(
+        hours.asInstanceOf[Int],
+        minutes.asInstanceOf[Int],
+        secs,
+        nanos)
+      localTimeToMicros(lt)
+    } catch {
+      case e: DateTimeException =>
+        throw QueryExecutionErrors.ansiDateTimeArgumentOutOfRangeWithoutSuggestion(e)
+    }
+  }
+
+  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {

Review Comment:
   Actually, I would prefer to avoid code duplication in codegen and in non-codegen, and just use `StaticInvoke`. Could you create a helper function in an object which takes 3 time components and returns micros, and just statically call it from the `MakeTime` expression.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2726042770

   @MaxGekk this is ready for review


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r1999362668


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala:
##########
@@ -2150,4 +2150,71 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
       condition = "INTERNAL_ERROR",
       parameters = Map("message" -> "Cannot evaluate expression: localtimestamp(Some(UTC))"))
   }
+
+  test("creating values of TimeType via make_time") {
+    Seq(true, false).foreach { ansi =>
+      withSQLConf(SQLConf.ANSI_ENABLED.key -> ansi.toString) {
+        // basic case
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(2, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          LocalTime.of(13, 2, 23, 500000000))
+
+        // Postgres compatibility
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(2, IntegerType),
+            Literal(Decimal(BigDecimal(60), 16, 6))),
+          LocalTime.of(13, 3, 0, 0))
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(59, IntegerType),
+            Literal(Decimal(BigDecimal(60), 16, 6))),
+          LocalTime.of(14, 0, 0, 0))
+
+        // null cases
+        checkEvaluation(
+          MakeTime(Literal.create(null, IntegerType), Literal(18),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(
+          MakeTime(Literal(13), Literal.create(null, IntegerType),
+            Literal(Decimal(BigDecimal(23.5), 16, 6))),
+          null)
+        checkEvaluation(MakeTime(Literal(13), Literal(18),
+          Literal.create(null, DecimalType(16, 6))), null)
+      }
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
+      // Invalid times return null
+      checkEvaluation(
+        MakeTime(Literal(Int.MaxValue), Literal(18),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(
+        MakeTime(Literal(13), Literal(Int.MinValue),
+          Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        null)
+      checkEvaluation(MakeTime(Literal(13), Literal(18),
+        Literal(Decimal(BigDecimal(65.1), 16, 6))), null)
+      checkEvaluation(MakeTime(Literal(13), Literal(18),
+        Literal(Decimal(BigDecimal(60.1), 16, 6))), null)
+    }
+
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      checkExceptionInExpression[DateTimeException](
+        MakeTime(Literal(25), Literal(2), Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        "Invalid value for HourOfDay")
+      checkExceptionInExpression[DateTimeException](
+        MakeTime(Literal(23), Literal(-1), Literal(Decimal(BigDecimal(23.5), 16, 6))),
+        "Invalid value for MinuteOfHour")
+      checkExceptionInExpression[DateTimeException](
+        MakeTime(Literal(23), Literal(12), Literal(Decimal(BigDecimal(100.5), 16, 6))),
+        "Invalid value for SecondOfMinute")
+
+      // Invalid Postgres compatability case where seconds=60 and has a fractional second
+      checkExceptionInExpression[DateTimeException](
+        MakeTime(Literal(23), Literal(12), Literal(Decimal(BigDecimal(60.5), 16, 6))),
+        "[INVALID_FRACTION_OF_SECOND] Valid range for seconds is [0, 60]")

Review Comment:
   Updated



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2032024267


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -160,3 +162,76 @@ object TryToTimeExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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)
+  extends TernaryExpression with ImplicitCastInputTypes with SecAndNanosExtractor {
+  override def nullIntolerant: Boolean = true
+
+  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 = children.exists(_.nullable)
+
+  override protected def nullSafeEval(hours: Any, minutes: Any, secAndMicros: Any): Any = {
+    val (secs, nanos) = toSecondsAndNanos(secAndMicros.asInstanceOf[Decimal])
+
+    try {
+      val lt = LocalTime.of(
+        hours.asInstanceOf[Int],
+        minutes.asInstanceOf[Int],
+        secs,
+        nanos)
+      localTimeToMicros(lt)
+    } catch {
+      case e: DateTimeException =>
+        throw QueryExecutionErrors.ansiDateTimeArgumentOutOfRangeWithoutSuggestion(e)
+    }
+  }
+
+  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {

Review Comment:
   Updated



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2036466026


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -763,4 +763,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
       throw QueryExecutionErrors.invalidDatetimeUnitError("TIMESTAMPDIFF", unit)
     }
   }
+
+  /**
+   * Converts separate time fields in a long that represents microseconds since the start of
+   * the day
+   * @param hours the hour, from 0 to 23
+   * @param minutes the minute, from 0 to 59
+   * @param secsAndMicros the second, from 0 to 59.999999
+   * @return Time time represented as microseconds since the start of the day
+   */
+  def timeToMicros(hours: Int, minutes: Int, secsAndMicros: Decimal): Long = {
+    assert(secsAndMicros.scale == 6,
+      s"Seconds fraction must have 6 digits for microseconds but got ${secsAndMicros.scale}")
+    val unscaledSecFrac = secsAndMicros.toUnscaledLong
+    val totalMicros = unscaledSecFrac.toInt // 8 digits cannot overflow Int
+    val fullSecs = Math.floorDiv(totalMicros, MICROS_PER_SECOND.toInt)
+    val nanos = Math.floorMod(totalMicros, MICROS_PER_SECOND.toInt) * NANOS_PER_MICROS.toInt

Review Comment:
   Updated



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "robreeves (via GitHub)" <gi...@apache.org>.
robreeves commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2036466242


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -763,4 +763,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
       throw QueryExecutionErrors.invalidDatetimeUnitError("TIMESTAMPDIFF", unit)
     }
   }
+
+  /**
+   * Converts separate time fields in a long that represents microseconds since the start of
+   * the day
+   * @param hours the hour, from 0 to 23
+   * @param minutes the minute, from 0 to 59
+   * @param secsAndMicros the second, from 0 to 59.999999
+   * @return Time time represented as microseconds since the start of the day
+   */
+  def timeToMicros(hours: Int, minutes: Int, secsAndMicros: Decimal): Long = {
+    assert(secsAndMicros.scale == 6,
+      s"Seconds fraction must have 6 digits for microseconds but got ${secsAndMicros.scale}")
+    val unscaledSecFrac = secsAndMicros.toUnscaledLong
+    val totalMicros = unscaledSecFrac.toInt // 8 digits cannot overflow Int

Review Comment:
   Updated to use suggestion in https://github.com/apache/spark/pull/50269#discussion_r2034817575



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #50269:
URL: https://github.com/apache/spark/pull/50269#issuecomment-2811800682

   @robreeves Congratulations with your first contribution to Apache Spark!


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-51414][SQL] Add the make_time() function [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #50269:
URL: https://github.com/apache/spark/pull/50269#discussion_r2034758745


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -290,3 +290,47 @@ object HourExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable
+    with ImplicitCastInputTypes
+    with ExpectsInputTypes {
+
+  override def inputTypes: Seq[AbstractDataType] = Seq(IntegerType, IntegerType, DecimalType(16, 6))
+  override def children: Seq[Expression] = Seq(hours, minutes, secsAndMicros)
+  override def dataType: DataType = TimeType(TimeType.MAX_PRECISION)
+  override def prettyName: String = "make_time"
+
+  override def replacement: Expression = StaticInvoke(
+    classOf[DateTimeUtils.type],
+    dataType,

Review Comment:
   In the near future, the max precision can be changed to nanoseconds, and you will have to fix all such places. Let's make the current implementation consistent, and set the return data type to `TimeType(TimeType.MICROS_PRECISION)`.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -290,3 +290,47 @@ object HourExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable
+    with ImplicitCastInputTypes
+    with ExpectsInputTypes {
+
+  override def inputTypes: Seq[AbstractDataType] = Seq(IntegerType, IntegerType, DecimalType(16, 6))
+  override def children: Seq[Expression] = Seq(hours, minutes, secsAndMicros)
+  override def dataType: DataType = TimeType(TimeType.MAX_PRECISION)

Review Comment:
   When you extend `RuntimeReplaceable`, the `dataType()` method returns `dataType` of `replacement`, see:
   ```scala
   trait RuntimeReplaceable extends Expression {
   ...
     override def dataType: DataType = replacement.dataType
   ```



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -290,3 +290,47 @@ object HourExpressionBuilder extends ExpressionBuilder {
     }
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(hour, minute, second) - Create time from hour, minute and second fields. For invalid inputs it will throw an error.",
+  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,
+    secsAndMicros: Expression)
+  extends RuntimeReplaceable
+    with ImplicitCastInputTypes
+    with ExpectsInputTypes {
+
+  override def inputTypes: Seq[AbstractDataType] = Seq(IntegerType, IntegerType, DecimalType(16, 6))

Review Comment:
   Could you add a comment from `MakeTimestamp` regarding the type `DecimalType(16, 6)`:
   ```
     // Accept `sec` as DecimalType to avoid loosing precision of microseconds while converting
     // them to the fractional part of `sec`. For accepts IntegerType as `sec` and integer can be
     // casted into decimal safely, we use DecimalType(16, 6) which is wider than DecimalType(10, 0).
   ```



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -763,4 +763,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
       throw QueryExecutionErrors.invalidDatetimeUnitError("TIMESTAMPDIFF", unit)
     }
   }
+
+  /**
+   * Converts separate time fields in a long that represents microseconds since the start of
+   * the day
+   * @param hours the hour, from 0 to 23
+   * @param minutes the minute, from 0 to 59
+   * @param secsAndMicros the second, from 0 to 59.999999
+   * @return Time time represented as microseconds since the start of the day
+   */
+  def timeToMicros(hours: Int, minutes: Int, secsAndMicros: Decimal): Long = {
+    assert(secsAndMicros.scale == 6,
+      s"Seconds fraction must have 6 digits for microseconds but got ${secsAndMicros.scale}")
+    val unscaledSecFrac = secsAndMicros.toUnscaledLong
+    val totalMicros = unscaledSecFrac.toInt // 8 digits cannot overflow Int

Review Comment:
   Could you clarify why 8 digits if the input type is `DecimalType(16, 6)`, please.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -763,4 +763,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
       throw QueryExecutionErrors.invalidDatetimeUnitError("TIMESTAMPDIFF", unit)
     }
   }
+
+  /**
+   * Converts separate time fields in a long that represents microseconds since the start of
+   * the day
+   * @param hours the hour, from 0 to 23
+   * @param minutes the minute, from 0 to 59
+   * @param secsAndMicros the second, from 0 to 59.999999
+   * @return Time time represented as microseconds since the start of the day
+   */
+  def timeToMicros(hours: Int, minutes: Int, secsAndMicros: Decimal): Long = {
+    assert(secsAndMicros.scale == 6,
+      s"Seconds fraction must have 6 digits for microseconds but got ${secsAndMicros.scale}")
+    val unscaledSecFrac = secsAndMicros.toUnscaledLong
+    val totalMicros = unscaledSecFrac.toInt // 8 digits cannot overflow Int
+    val fullSecs = Math.floorDiv(totalMicros, MICROS_PER_SECOND.toInt)
+    val nanos = Math.floorMod(totalMicros, MICROS_PER_SECOND.toInt) * NANOS_PER_MICROS.toInt

Review Comment:
   Why do you cast to `Int` explicitly? I guess ops over `Long` as much performant as over `Int` on modern CPUs. How about:
   ```scala
       try {
         val unscaledSecFrac = secsAndMicros.toUnscaledLong
         val fullSecs = Math.floorDiv(unscaledSecFrac, MICROS_PER_SECOND)
         val nanos = Math.floorMod(unscaledSecFrac, MICROS_PER_SECOND) * NANOS_PER_MICROS
         val lt = LocalTime.of(hours, minutes, fullSecs.toInt, nanos.toInt)
         localTimeToMicros(lt)
       } catch {
         case e @ (_: DateTimeException | _: ArithmeticException) =>
           throw QueryExecutionErrors.ansiDateTimeArgumentOutOfRangeWithoutSuggestion(e)
       }
   ```
   
   Could you add tests for the function `timeToMicros` to `DateTimeUtilsSuite`, and check the corner cases like:
   - secsAndMicros = 9999999999.999999, the max value of the type DecimalType(16, 6).
   - secsAndMicros = -999999999.999999
   - secsAndMicros = 60.0
   - hours = -1 or 24
   - minutes = -1 or 24



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -763,4 +763,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
       throw QueryExecutionErrors.invalidDatetimeUnitError("TIMESTAMPDIFF", unit)
     }
   }
+
+  /**
+   * Converts separate time fields in a long that represents microseconds since the start of
+   * the day
+   * @param hours the hour, from 0 to 23
+   * @param minutes the minute, from 0 to 59
+   * @param secsAndMicros the second, from 0 to 59.999999
+   * @return Time time represented as microseconds since the start of the day

Review Comment:
   ```suggestion
      * @return A time value represented as microseconds since the start of the day
   ```



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org