Renukaprasad C created HIVE-23927:
-------------------------------------

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


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)

Reply via email to