MaxGekk commented on a change in pull request #31000:
URL: https://github.com/apache/spark/pull/31000#discussion_r551766700



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala
##########
@@ -323,6 +323,39 @@ class DateFunctionsSuite extends QueryTest with 
SharedSparkSession {
         Row(Timestamp.valueOf("2015-12-27 00:00:00"))))
   }
 
+  test("function add_hours") {
+    val t1 = Timestamp.valueOf("2015-10-01 00:00:01")
+    val t2 = Timestamp.valueOf("2016-02-29 00:00:02")
+    val df = Seq((1, t1), (2, t2)).toDF("n", "t")

Review comment:
       Do you use the `n` column somewhere?

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -1445,6 +1445,40 @@ case class ToUTCTimestamp(left: Expression, right: 
Expression) extends UTCTimest
   override val prettyName: String = "to_utc_timestamp"
 }
 
+
+
+case class AddHours(startTime: Expression, numHours: Expression, timeZoneId: 
Option[String] = None)
+  extends BinaryExpression with ImplicitCastInputTypes with NullIntolerant
+    with TimeZoneAwareExpression {

Review comment:
       Please, fix indentation according to 
https://github.com/databricks/scala-style-guide#spacing-and-indentation

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -1445,6 +1445,40 @@ case class ToUTCTimestamp(left: Expression, right: 
Expression) extends UTCTimest
   override val prettyName: String = "to_utc_timestamp"
 }
 
+
+

Review comment:
       Could you remove the empty lines, please.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
##########
@@ -574,6 +574,21 @@ object DateTimeUtils {
     localDateToDays(daysToLocalDate(days).plusMonths(months))
   }
 
+  /**
+   * Adds hours to a timestamp represented as the number of
+   * microseconds since 1970-01-01 00:00:00Z.
+   * @return A timestamp value, expressed in microseconds since 1970-01-01 
00:00:00Z.
+   */
+  def timestampAddHours(
+    start: Long,
+    hours: Int,
+    zoneId: ZoneId): Long = {

Review comment:
       ```suggestion
         start: Long,
         hours: Int,
         zoneId: ZoneId): Long = {
   ```
   see https://github.com/databricks/scala-style-guide#spacing-and-indentation

##########
File path: sql/core/src/main/scala/org/apache/spark/sql/functions.scala
##########
@@ -2841,6 +2841,20 @@ object functions {
   // DateTime functions
   
//////////////////////////////////////////////////////////////////////////////////////////////
 
+  /**
+   * Returns the timestamp that is `numHours` after `startTime`.
+   *
+   * @param startTime A date, timestamp or string. If a string, the data must 
be in a format that
+   *                  can be cast to a date, such as `yyyy-MM-dd` or 
`yyyy-MM-dd HH:mm:ss.SSSS`
+   * @param numHours The number of hours to add to `startTime`, can be 
negative to subtract hours
+   * @return A timestamp, or null if `startTime` was a string that could not 
be cast to a timestamp
+   * @group datetime_funcs
+   * @since TBD

Review comment:
       3.2.0




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to