[
https://issues.apache.org/jira/browse/HIVE-23927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17176438#comment-17176438
]
Panagiotis Garefalakis commented on HIVE-23927:
-----------------------------------------------
I guess the main issue here is
*PrimitiveObjectInspectorUtils.getTimestamp(Object, PrimitiveObjectInspector,
boolean)*.
For int:
https://github.com/apache/hive/blob/6ceeea87a34f53add62fa6d0a332b06b8863c440/serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampWritableV2.java#L531
*intToTimestampInSeconds = false *
https://github.com/apache/hive/blob/1758c8c857f8a6dc4c9dc9c522de449f53e5e5cc/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java#L1181
While for double:
https://github.com/apache/hive/blob/e6900fea9108b2dd00f0e4bf2a598f6fc9ba01cf/common/src/java/org/apache/hadoop/hive/common/type/TimestampUtils.java#L43
Not sure where the assumption that Double is in seconds comes from ?
Maybe we should make this configurable as well -- as we do in *longToTimestamp*
method
> Cast to Timestamp generates different output for Integer & Float values
> ------------------------------------------------------------------------
>
> Key: HIVE-23927
> URL: https://issues.apache.org/jira/browse/HIVE-23927
> Project: Hive
> Issue Type: Bug
> Reporter: Renukaprasad C
> Priority: Major
>
> Double consider the input value as SECOND and converts into Millis internally.
> Whereas, Integer value will be considered as Millis and produce different
> output.
> org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getTimestamp(Object,
> PrimitiveObjectInspector, boolean) - Handles Integral & Decimal values
> differently. This cause the issue.
> 0: jdbc:hive2://localhost:10000> select cast(1.204135216E9 as timestamp)
> Double2TimeStamp, cast(1204135216 as timestamp) Int2TimeStamp from abc
> tablesample(1 rows);
> OK
> INFO : Compiling
> command(queryId=renu_20200724140642_70132390-ee12-4214-a2ca-a7e10556fc14):
> select cast(1.204135216E9 as timestamp) Double2TimeStamp, cast(1204135216 as
> timestamp) Int2TimeStamp from abc tablesample(1 rows)
> INFO : Concurrency mode is disabled, not creating a lock manager
> INFO : Semantic Analysis Completed (retrial = false)
> INFO : Returning Hive schema:
> Schema(fieldSchemas:[FieldSchema(name:double2timestamp, type:timestamp,
> comment:null), FieldSchema(name:int2timestamp, type:timestamp,
> comment:null)], properties:null)
> INFO : Completed compiling
> command(queryId=renu_20200724140642_70132390-ee12-4214-a2ca-a7e10556fc14);
> Time taken: 0.175 seconds
> INFO : Concurrency mode is disabled, not creating a lock manager
> INFO : Executing
> command(queryId=renu_20200724140642_70132390-ee12-4214-a2ca-a7e10556fc14):
> select cast(1.204135216E9 as timestamp) Double2TimeStamp, cast(1204135216 as
> timestamp) Int2TimeStamp from abc tablesample(1 rows)
> INFO : Completed executing
> command(queryId=renu_20200724140642_70132390-ee12-4214-a2ca-a7e10556fc14);
> Time taken: 0.001 seconds
> INFO : OK
> INFO : Concurrency mode is disabled, not creating a lock manager
> +------------------------+--------------------------+
> | double2timestamp | int2timestamp |
> +------------------------+--------------------------+
> | 2008-02-27 18:00:16.0 | 1970-01-14 22:28:55.216 |
> +------------------------+--------------------------+
--
This message was sent by Atlassian Jira
(v8.3.4#803005)