warriersruthi commented on a change in pull request #2550:
URL: https://github.com/apache/hive/pull/2550#discussion_r681797171
##########
File path: ql/src/test/queries/clientpositive/udf5.q
##########
@@ -13,6 +13,8 @@ SELECT from_unixtime(unix_timestamp('2010-01-13 11:57:40',
'yyyy-MM-dd HH:mm:ss'
SELECT from_unixtime(unix_timestamp('2010-01-13 11:57:40', 'yyyy-MM-dd
HH:mm:ss'), 'MM/dd/yy HH:mm:ss'), from_unixtime(unix_timestamp('2010-01-13
11:57:40')) from dest1_n14;
+SELECT from_unixtime(unix_timestamp(cast('2010-01-13' as date)));
Review comment:
Done
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUnixTime.java
##########
@@ -153,23 +127,14 @@ public Object evaluate(DeferredObject[] arguments) throws
HiveException {
unixtime = inputLongOI.get(arguments[0].get());
}
- Date date = new Date(unixtime * 1000L);
- result.set(formatter.format(date));
+ Instant i = Instant.ofEpochSecond(unixtime);
+ ZonedDateTime z = ZonedDateTime.ofInstant(i, timeZone);
+ result.set(z.format(FORMATTER));
return result;
}
- protected String getName() {
- return "from_unixtime";
- }
-
@Override
public String getDisplayString(String[] children) {
- StringBuilder sb = new StringBuilder(32);
- sb.append(getName());
- sb.append('(');
- sb.append(StringUtils.join(children, ", "));
- sb.append(')');
- return sb.toString();
+ return getStandardDisplayString(getFuncName(), children, ", ");
}
-
-}
+}
Review comment:
Done
--
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]