Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-24389

Trailing zeros of constant decimal numbers are removed

Log workAgile BoardRank to TopRank to BottomVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Types

      Description

      In some case Hive removes trailing zeros of constant decimal numbers

      select cast(1.1 as decimal(22, 2)) 
      1.1
      

      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:

      this = {WritableConstantHiveDecimalObjectInspector@14415} 
       value = {HiveDecimalWritable@14426} "1.1"
       typeInfo = {DecimalTypeInfo@14421} "decimal(22,2)"

      However in case of an expression with an aggregate function WritableHiveDecimalObjectInspector is used

      select cast(sum(1.1) as decimal(22, 2))
      1.10
      
      o = {HiveDecimalWritable@16633} "1.1"
      oi = {WritableHiveDecimalObjectInspector@16634} 
       typeInfo = {DecimalTypeInfo@16640} "decimal(22,2)"
      

      Casting the expressions to string

      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
      

        Attachments

        Issue Links

          Activity

          $i18n.getText('security.level.explanation', $currentSelection) Viewable by All Users
          Cancel

            People

            • Assignee:
              kkasa Krisztian Kasa Assign to me
              Reporter:
              kkasa Krisztian Kasa

              Dates

              • Created:
                Updated:
                Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 2h
              2h

                Issue deployment