Krisztian Kasa created HIVE-24389:
-------------------------------------

             Summary: 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


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)

Reply via email to