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

Matt McCline commented on HIVE-13914:
-------------------------------------

ORC
The FloatTreeReader.nextVector reads the first float as:
-35664.76
and stores it into the DoubleColumnVector.vector (double[]) where it displays 
as:
-35664.76171875
And, FloatTreeReader.nextVector reads the second float as:
29497.34
and stores it into the DoubleColumnVector.vector (double[]) where it displays 
as:
29497.33984375
For the query looking at the original data type float, the 
RecordReaderImpl.nextFloat casts the DoubleColumnVector.vector entry to float 
and sets the FloatWritable. The values -35664.76 and 29497.34 reappear.
For the 2nd query after changing the data type to double, the 
RecordReaderImpl.nextDouble just stores the DoubleColumnVector.vector entry in 
the DoubleWritable. The values with more digits -35664.76171875 and 
29497.33984375 are returned.
--------------
TEXTFILE
The float values are stored as text fields "-35664.76" and "29497.34" and there 
is no conversion because we are using a table. There is just a new 
interpretation of the field.
The first query reads those fields as float and the second query after changing 
the data type to double reads the text fields as double.

> Changing a column of orc table from float to double adds some fractional 
> digits
> -------------------------------------------------------------------------------
>
>                 Key: HIVE-13914
>                 URL: https://issues.apache.org/jira/browse/HIVE-13914
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 2.1.0
>            Reporter: Takahiko Saito
>
> Some fractional digits are added after altering a float column of an orc 
> table to double:
> {noformat}
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> drop table test;
> No rows affected (0.233 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4>
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4>
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> create table test (f float) 
> stored as orc;
> No rows affected (0.095 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> insert into table test 
> values(-35664.76),(29497.34);
> No rows affected (2.206 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> select * from test;
> +------------+--+
> |   test.f   |
> +------------+--+
> | -35664.76  |
> | 29497.34   |
> +------------+--+
> 2 rows selected (0.131 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> alter table test change column 
> f f double;
> No rows affected (0.183 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> select * from test;
> +------------------+--+
> |      test.f      |
> +------------------+--+
> | -35664.76171875  |
> | 29497.33984375   |
> +------------------+--+
> 2 rows selected (0.114 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4>
> {noformat}
> The issue is NOT seen with text formatted table:
> {noformat}
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> create table test (f float) ;
> No rows affected (0.131 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> insert into table test 
> values(-35664.76),(29497.34);
> No rows affected (2.114 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> select * from test;
> +------------+--+
> |   test.f   |
> +------------+--+
> | -35664.76  |
> | 29497.34   |
> +------------+--+
> 2 rows selected (0.163 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> alter table test change column 
> f f double;
> No rows affected (0.184 seconds)
> 0: jdbc:hive2://os-r7-mvjkcu-hiveserver2-11-4> select * from test;
> +------------+--+
> |   test.f   |
> +------------+--+
> | -35664.76  |
> | 29497.34   |
> +------------+--+
> 2 rows selected (0.11 seconds)
> {noformat}



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

Reply via email to