Uploaded image for project: 'Livy'
  1. Livy
  2. LIVY-771

Thrift server returns decimal value with trailing zeros removed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.6.0, 0.7.0
    • 0.9.0
    • Thriftserver
    • None

    Description

      I have been doing some Hive interop testing. I have a Hive table with a column, f_decimal decimal(5, 2).
      I run a query to select f_decimal from the table. I run this in Hive (HS2) through beeline, as well as in the Livy Thrift server through beeline. In the case of Hive, the decimal values are shown with the correct scale (2 places to the right of the decimal point) in all cases, while in the case of the Livy TS, the decimal values that have trailing zeros are shown with trailing zeros removed. E.g., 9.40 in Hive vs 9.4 in Livy; 713.00 in Hive vs 713 in Livy. (I did not actually have this in my table, but 120.00 in Hive would be 1.2E+2 in Livy.)
      E.g.,
      beeline to HS2:

      > select f_decimal from hive_types_test order by f_int limit 1;
      +------------+
      | f_decimal  |
      +------------+
      | 9.40       |
      +------------+
      1 row selected (14.31 seconds)
      

      beeline to Livy TS:

      > select f_decimal from hive_types_test order by f_int limit 1;
      +------------+
      | f_decimal  |
      +------------+
      | 9.4        |
      +------------+
      1 row selected (11.544 seconds)
      

      If the column type is decimal(5, 2), then the values should be shown with the correct scale. Also, the results should, where possible, be the same in Livy as in Hive.
      However, this is not merely a display issue. It manifests at the JDBC level. If you connect to the Livy Thrift server using JDBC, execute a query and get a java.sql.ResultSet, then ResultSet#getBigDecimal on the index of a column of decimal type returns a BigDecimal value of incorrect scale in the above case.

      Attachments

        Activity

          People

            Unassigned Unassigned
            wypoon Wing Yew Poon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

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