Pavel Benes created HIVE-15416:
----------------------------------

             Summary: CAST to string does not work for large decimal numbers
                 Key: HIVE-15416
                 URL: https://issues.apache.org/jira/browse/HIVE-15416
             Project: Hive
          Issue Type: Bug
    Affects Versions: 1.2.1
            Reporter: Pavel Benes


The cast of large decimal values to string does not work and produces NULL 
values. 
Steps to reproduce:
{code}
hive> create table test_hive_bug30(decimal_col DECIMAL(30,0));
OK
{code}
hive> insert into test_hive_bug30 VALUES (123), 
(99999999999999999999999999999), 
(999999999999999999999999999999),(9999999999999999999999999999999);
Query ID = benesp_20161212135717_5d16d7f4-7b84-409e-ad00-36085deaae54
Total jobs = 1
Launching Job 1 out of 1


Status: Running (Executing on YARN cluster with App id 
application_1480833176011_2469)

--------------------------------------------------------------------------------
        VERTICES      STATUS  TOTAL  COMPLETED  RUNNING  PENDING  FAILED  KILLED
--------------------------------------------------------------------------------
Map 1 ..........   SUCCEEDED      1          1        0        0       0       0
--------------------------------------------------------------------------------
VERTICES: 01/01  [==========================>>] 100%  ELAPSED TIME: 7.69 s
--------------------------------------------------------------------------------
Loading data to table default.test_hive_bug30
Table default.test_hive_bug30 stats: [numFiles=1, numRows=4, totalSize=68, 
rawDataSize=64]
OK
Time taken: 8.239 seconds
{code}
hive> select CAST(decimal_col AS STRING) from test_hive_bug30;
OK
123
NULL
NULL
NULL
Time taken: 0.043 seconds, Fetched: 4 row(s)
{code}

The numbers with 29 and 30 digits should be exported, but they are converted to 
NULL instead. 
The values are stored correctly as can be seen here:
{code}
hive> select * from test_hive_bug30;
OK
123
99999999999999999999999999999
999999999999999999999999999999
NULL
Time taken: 0.447 seconds, Fetched: 4 row(s)
{code}

The same issue does not exists for smaller numbers (e.g. DECIMAL(10)).






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

Reply via email to