Details
-
Bug
-
Status: Patch Available
-
Critical
-
Resolution: Unresolved
-
3.1.2
-
None
-
None
Description
when I use unix_timestamp udf,What this function actually calls is to_unix_timestamp udf.This return result is incorrect.Here is my SQL:
//代码占位符 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hive/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hadoop-3.2.1/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Hive Session ID = 3a04a9cf-1fdb-4017-a4bb-14763a3163c7Logging initialized using configuration in file:/usr/local/hive/conf/hive-log4j2.properties Async: true Hive Session ID = 92ca916b-cfde-43b5-bd86-10d50ff7d861 Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases. hive> select unix_timestamp('2021-09-24 00:00:00'); OK 1632441600 Time taken: 3.729 seconds, Fetched: 1 row(s)
We see GenericUDFToUnixTimeStamp class code,I found that the fixed time zone is set UTC, not according to the user time zone.Time zones vary with users,My time zone is Asia/Shanghai .Therefore, the function should use the user time zone Here is the code I modified
//代码占位符 SessionState ss = SessionState.get(); String timeZoneStr = ss.getConf().get("hive.local.time.zone"); if (timeZoneStr == null || timeZoneStr.trim().isEmpty() || timeZoneStr.toLowerCase().equals("local")) { timeZoneStr = System.getProperty("user.timezone"); } formatter.setTimeZone(TimeZone.getTimeZone(timeZoneStr));
Attachments
Attachments
Issue Links
- relates to
-
HIVE-21067 TO_UNIX_TIMESTAMP (or UNIX_TIMESTAMP) treats argument timestamp as UTC
- Open
-
HIVE-25577 unix_timestamp() is ignoring the time zone value
- Closed
-
HIVE-319 add UDF UNIX_TIMESTAMP
- Closed