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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -3011,13 +3011,17 @@ object SubtractDates {
   arguments = """
     Arguments:
       * sourceTz - the time zone for the input timestamp
+          - if not specified, SESSION_LOCAL_TIMEZONE is used when sourceTs is 
timestamp_ntz,

Review comment:
       `SESSION_LOCAL_TIMEZONE` is not valid for end users. Point out the SQL 
config `spark.sql.session.timeZone` or better `SESSION_LOCAL_TIMEZONE.key`

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -3028,6 +3032,15 @@ case class ConvertTimezone(
     sourceTs: Expression)
   extends TernaryExpression with ImplicitCastInputTypes with NullIntolerant {
 
+  def this(targetTz: Expression, sourceTs: Expression) = {
+    this(
+      Literal(SQLConf.get.sessionLocalTimeZone),

Review comment:
       Please, make the expression as time zone aware via extending 
`TimeZoneAwareExpression`.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -3028,6 +3032,15 @@ case class ConvertTimezone(
     sourceTs: Expression)
   extends TernaryExpression with ImplicitCastInputTypes with NullIntolerant {
 
+  def this(targetTz: Expression, sourceTs: Expression) = {
+    this(
+      Literal(SQLConf.get.sessionLocalTimeZone),
+      targetTz,
+      if (sourceTs.dataType == TimestampNTZType) sourceTs
+      else Cast(sourceTs, TimestampNTZType)

Review comment:
       How other types can appear if this below
   ```scala
   override def inputTypes: Seq[AbstractDataType] = Seq(StringType, StringType, 
TimestampNTZType)
   ```
   accepts only `TimestampNTZType`. Could add an end-to-end tests to 
`timestamp-ltz.sql` like
   
https://github.com/apache/spark/blob/master/sql/core/src/test/resources/sql-tests/inputs/timestamp-ntz.sql#L19
 




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