[
https://issues.apache.org/jira/browse/HIVE-11835?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14790853#comment-14790853
]
Xuefu Zhang edited comment on HIVE-11835 at 9/16/15 6:42 PM:
-------------------------------------------------------------
The problem is caused by the fact that Hive trims zeros. In most of cases this
is harmless. However, if the value is 0.0, 0.00, 0.000, etc, trimming zeros
changes the value to 0, which has a type decimal(1,0). Since type decimal(1, 1)
allows on integer digits, 0 becomes NULL when being converted to decimal(1, 1).
It seems that trimming trailing zeros doesn't do any good. It not only changes
the data type, creating the problem like the one here, but also completely
changes the semantic meaning of the number. The right fix is to keep trailing
zeros only if it goes beyond the datatype allows, which happens when scale is
enforced. This will also keeps the right number of decimal points on query
result, which is desirable and common practice in other DBs.
Initial patch to have a test run. Expect some test results need to be updated.
Will also add new tests.
was (Author: xuefuz):
Initial patch to have a test run. Expect some test results need to be updated.
Will also add new tests.
> Type decimal(1,1) reads 0.0, 0.00, etc from text file as NULL
> -------------------------------------------------------------
>
> Key: HIVE-11835
> URL: https://issues.apache.org/jira/browse/HIVE-11835
> Project: Hive
> Issue Type: Bug
> Components: Types
> Affects Versions: 1.2.0, 1.1.0, 2.0.0
> Reporter: Xuefu Zhang
> Assignee: Xuefu Zhang
> Attachments: HIVE-11835.patch
>
>
> Steps to reproduce:
> 1. create a text file with values like 0.0, 0.00, etc.
> 2. create table in hive with type decimal(1,1).
> 3. run "load data local inpath ..." to load data into the table.
> 4. run select * on the table.
> You will see that NULL is displayed for 0.0, 0.00, .0, etc. Instead, these
> should be read as 0.0.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)