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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -2422,6 +2429,16 @@ case class MakeTimestamp(
     val failOnErrorBranch = if (failOnError) "throw e;" else s"${ev.isNull} = 
true;"
     nullSafeCodeGen(ctx, ev, (year, month, day, hour, min, secAndNanos, 
timezone) => {
       val zoneId = timezone.map(tz => 
s"$dtu.getZoneId(${tz}.toString())").getOrElse(zid)
+      val toMicrosCode = if (dataType == TimestampType) {
+        s"""
+           |java.time.Instant instant = ldt.atZone($zoneId).toInstant();
+           |${ev.value} = $dtu.instantToMicros(instant);
+           |""".stripMargin
+      } else {
+        s"""
+           |${ev.value} = $dtu.localDateTimeToMicros(ldt);
+           |""".stripMargin

Review comment:
       ```suggestion
           s"${ev.value} = $dtu.localDateTimeToMicros(ldt);"
   ```

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -2286,7 +2286,8 @@ case class MakeDate(
 
 // scalastyle:off line.size.limit
 @ExpressionDescription(
-  usage = "_FUNC_(year, month, day, hour, min, sec[, timezone]) - Create 
timestamp from year, month, day, hour, min, sec and timezone fields.",
+  usage = "_FUNC_(year, month, day, hour, min, sec[, timezone]) - Create 
timestamp from year, month, day, hour, min, sec and timezone fields. " +
+    "The result data type is consistent with the value of configuration 
`spark.sql.timestampType`",

Review comment:
       Please, use TIMESTAMP_TYPE.key. Using the SQL config has some benefits 
like:
   - Easer to search in IDE by config name
   - Refactoring. Maybe, we will rename it in the future. So, you will not need 
to modify this place.




-- 
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: [email protected]

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