You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Sergio Peña (JIRA)" <ji...@apache.org> on 2016/06/10 16:26:21 UTC

[jira] [Commented] (HIVE-13908) Beeline adds extra fractional digits when you insert values to table with float data type

    [ https://issues.apache.org/jira/browse/HIVE-13908?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15324738#comment-15324738 ] 

Sergio Peña commented on HIVE-13908:
------------------------------------

This issue is related to a Thrift communication. 

The FLOAT data is correctly loaded on HS2, but in order to send it to beeline, it needs to cast it as DOUBLE because Thrift does not support FLOAT data types. This is where the decimals got extended. 

This is the code where it happens:
https://github.com/apache/hive/blob/master/serde/src/java/org/apache/hadoop/hive/serde2/thrift/ColumnBuffer.java#L368

{noformat}
case FLOAT_TYPE:
      nulls.set(size, field == null);
      doubleVars()[size] = field == null ? 0 : new Double(field.toString());
      break;
{noformat}

> Beeline adds extra fractional digits when you insert values to table with float data type 
> ------------------------------------------------------------------------------------------
>
>                 Key: HIVE-13908
>                 URL: https://issues.apache.org/jira/browse/HIVE-13908
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 1.2.1
>            Reporter: Takahiko Saito
>
> Via beeline, although -35664.76 is inserted,  -35664.76171875 is displayed
> {noformat}
> 0: jdbc:hive2://ts-0531-1.openstacklocal:2181> drop table test;
> No rows affected (0.067 seconds)
> 0: jdbc:hive2://ts-0531-1.openstacklocal:2181> create table test(f float);
> No rows affected (0.248 seconds)
> 0: jdbc:hive2://ts-0531-1.openstacklocal:2181> insert into table test values(-35664.76),(29497.34);
> INFO  : Tez session hasn't been created yet. Opening session
> INFO  : Dag name: insert into table tes...35664.76),(29497.34)(Stage-1)
> INFO  :
> INFO  : Status: Running (Executing on YARN cluster with App id application_1464727816747_0019)
> INFO  : Map 1: -/-
> INFO  : Map 1: 0/1
> INFO  : Map 1: 0/1
> INFO  : Map 1: 0(+1)/1
> INFO  : Map 1: 1/1
> INFO  : Loading data to table default.test from hdfs://ts-0531-5.openstacklocal:8020/apps/hive/warehouse/test/.hive-staging_hive_2016-06-01_20-16-32_885_9161749848563358684-1/-ext-10000
> INFO  : Table default.test stats: [numFiles=1, numRows=2, totalSize=19, rawDataSize=17]
> No rows affected (31.725 seconds)
> 0: jdbc:hive2://ts-0531-1.openstacklocal:2181> select * from test;
> +------------------+--+
> |      test.f      |
> +------------------+--+
> | -35664.76171875  |
> | 29497.33984375   |
> +------------------+--+
> 2 rows selected (0.143 seconds)
> {noformat}
> The issue is not seen via Hive CLI:
> {noformat}
> hive> create table test(f float);
> OK
> Time taken: 0.32 seconds
> hive> insert into table test values(-35664.76),(29497.34);
> Query ID = hrt_qa_20160601202446_75f38c5d-f52b-45b3-b67a-8a8b0a194305
> Total jobs = 1
> Launching Job 1 out of 1
> Status: Running (Executing on YARN cluster with App id application_1464727816747_0020)
> --------------------------------------------------------------------------------
>         VERTICES      STATUS  TOTAL  COMPLETED  RUNNING  PENDING  FAILED  KILLED
> --------------------------------------------------------------------------------
> Map 1 ..........   SUCCEEDED      1          1        0        0       0       0
> --------------------------------------------------------------------------------
> VERTICES: 01/01  [==========================>>] 100%  ELAPSED TIME: 7.66 s
> --------------------------------------------------------------------------------
> Loading data to table default.test
> Table default.test stats: [numFiles=1, numRows=2, totalSize=19, rawDataSize=17]
> OK
> Time taken: 11.477 seconds
> hive> select * from test;
> OK
> -35664.76
> 29497.34
> Time taken: 0.144 seconds, Fetched: 2 row(s)
> {noformat}
> hdfs file shows expected value:
> {noformat}
> 0: jdbc:hive2://ts-0531-1.openstacklocal:2181> dfs -cat hdfs://ts-0531-5.openstacklocal:8020/apps/hive/warehouse/test/000000_0
> 0: jdbc:hive2://ts-0531-1.openstacklocal:2181> ;
> +-------------+--+
> | DFS Output  |
> +-------------+--+
> | -35664.76   |
> | 29497.34    |
> +-------------+--+
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)