[
https://issues.apache.org/jira/browse/HIVE-15416?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15771131#comment-15771131
]
Daniel Dai commented on HIVE-15416:
-----------------------------------
Yes, it is fair to still consider it is a bug, as UDFToString is a builtin UDF
and is implicitly invoked by Hive. We shall convert all builtin UDFs to
GenericUDF. As for length of varchar, I should say it is varchar(41) to avoid
the situation you described, the size is just a maximum.
> 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
> Assignee: Daniel Dai
>
> 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}
> {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}
> {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)