zratkai commented on code in PR #5014:
URL: https://github.com/apache/hive/pull/5014#discussion_r1475967779
##########
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java:
##########
@@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hive.ql.udf.generic;
+import java.util.Arrays;
Review Comment:
Done.
##########
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFToUtcTimestamp.java:
##########
@@ -44,7 +46,11 @@ public String getName() {
}
@Override
- protected boolean invert() {
- return true;
+ protected TimeZone getToTimeZone(TimeZone timezone) {
+ return tzUTC;
Review Comment:
I did a refactor here. Previously there was this function which seemed weird:
protected boolean invert() {
return false;
}
Instead I created two methods:
getToTimeZone
getFromTimeZone
and they are used in:
GenericUDFToUtcTimestamp.java
GenericUDFFromUtcTimestamp.java
and one returns the input, the other not, this is true for both methods.
This is the logic behind toUTC or fromUTC.
##########
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java:
##########
@@ -88,18 +90,15 @@ public Object evaluate(DeferredObject[] arguments) throws
HiveException {
Timestamp inputTs = ((TimestampWritableV2) converted_o0).getTimestamp();
String tzStr = textConverter.convert(o1).toString();
- TimeZone timezone = TimeZone.getTimeZone(tzStr);
-
- TimeZone fromTz;
- TimeZone toTz;
- if (invert()) {
- fromTz = timezone;
- toTz = tzUTC;
- } else {
- fromTz = tzUTC;
- toTz = timezone;
+ if (ZoneInfo.getTimeZone(tzStr)==null && !tzStr.startsWith("GMT")) {
Review Comment:
Fixed.
##########
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUtcTimestamp.java:
##########
@@ -113,6 +112,14 @@ public Object evaluate(DeferredObject[] arguments) throws
HiveException {
return result;
}
+ protected TimeZone getToTimeZone(TimeZone timezone) {
+ return timezone;
+ }
+
+ protected TimeZone getFromTimeZone(TimeZone timezone) {
Review Comment:
I did a refactor here. Previously there was this function which seemed weird:
protected boolean invert() {
return false;
}
Instead I created two methods:
getToTimeZone
getFromTimeZone
and they are used in:
GenericUDFToUtcTimestamp.java
GenericUDFFromUtcTimestamp.java
and one returns the input, the other not, this is true for both methods.
This is the logic behind toUTC or fromUTC.
--
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]