You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/11/16 13:33:00 UTC

[jira] [Work logged] (HIVE-24389) Trailing zeros of constant decimal numbers are removed

     [ https://issues.apache.org/jira/browse/HIVE-24389?focusedWorklogId=512363&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-512363 ]

ASF GitHub Bot logged work on HIVE-24389:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Nov/20 13:32
            Start Date: 16/Nov/20 13:32
    Worklog Time Spent: 10m 
      Work Description: kasakrisz opened a new pull request #1676:
URL: https://github.com/apache/hive/pull/1676


   ### What changes were proposed in this pull request?
   In some case Hive removes trailing zeros of constant decimal numbers
   ```
   select cast(cast(1.1 as decimal(22, 2)) as string), cast(cast(sum(1.1) as decimal(22, 2)) as string)
   1.1	1.10
   ```
   Postgres returns `1.10` for both expressions.
   ### Why are the changes needed?
   Padding decimal values with trailing zeros is not consistent.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. With this patch Hive will pad constant decimal values with trailing zeros up to the specified scale.
   
   ### How was this patch tested?
   1.Run queries mentioned in the jira.
   2. Added test case to `decimal_2.q`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 512363)
    Remaining Estimate: 0h
            Time Spent: 10m

> Trailing zeros of constant decimal numbers are removed
> ------------------------------------------------------
>
>                 Key: HIVE-24389
>                 URL: https://issues.apache.org/jira/browse/HIVE-24389
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> In some case Hive removes trailing zeros of constant decimal numbers
> {code}
> select cast(1.1 as decimal(22, 2)) 
> 1.1
> {code}
> In this case *WritableConstantHiveDecimalObjectInspector* is used and this object inspector takes it's wrapped HiveDecimal scale instead of the scale specified in the wrapped typeinfo: 
> {code}
> this = {WritableConstantHiveDecimalObjectInspector@14415} 
>  value = {HiveDecimalWritable@14426} "1.1"
>  typeInfo = {DecimalTypeInfo@14421} "decimal(22,2)"{code}
> However in case of an expression with an aggregate function *WritableHiveDecimalObjectInspector* is used
> {code}
> select cast(sum(1.1) as decimal(22, 2))
> 1.10
> {code}
> {code}
> o = {HiveDecimalWritable@16633} "1.1"
> oi = {WritableHiveDecimalObjectInspector@16634} 
>  typeInfo = {DecimalTypeInfo@16640} "decimal(22,2)"
> {code}
> Casting the expressions to string
> {code:java}
> select cast(cast(1.1 as decimal(22, 2)) as string), cast(cast(sum(1.1) as decimal(22, 2)) as string)
> 1.1	1.10
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)