You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@livy.apache.org by "Wing Yew Poon (Jira)" <ji...@apache.org> on 2020/05/23 22:28:00 UTC

[jira] [Updated] (LIVY-771) Thrift server returns decimal value with trailing zeros removed

     [ https://issues.apache.org/jira/browse/LIVY-771?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wing Yew Poon updated LIVY-771:
-------------------------------
    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:
{noformat}
> select f_decimal from hive_types_test order by f_int limit 1;
+------------+
| f_decimal  |
+------------+
| 9.40       |
+------------+
1 row selected (14.31 seconds)
{noformat}
beeline to Livy TS:
{noformat}
> select f_decimal from hive_types_test order by f_int limit 1;
+------------+
| f_decimal  |
+------------+
| 9.4        |
+------------+
1 row selected (11.544 seconds)
{noformat}
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.


  was:
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.)
I would argue that this is incorrect behavior (a bug). 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.



> Thrift server returns decimal value with trailing zeros removed
> ---------------------------------------------------------------
>
>                 Key: LIVY-771
>                 URL: https://issues.apache.org/jira/browse/LIVY-771
>             Project: Livy
>          Issue Type: Bug
>          Components: Thriftserver
>    Affects Versions: 0.6.0, 0.7.0
>            Reporter: Wing Yew Poon
>            Priority: Major
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> 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:
> {noformat}
> > select f_decimal from hive_types_test order by f_int limit 1;
> +------------+
> | f_decimal  |
> +------------+
> | 9.40       |
> +------------+
> 1 row selected (14.31 seconds)
> {noformat}
> beeline to Livy TS:
> {noformat}
> > select f_decimal from hive_types_test order by f_int limit 1;
> +------------+
> | f_decimal  |
> +------------+
> | 9.4        |
> +------------+
> 1 row selected (11.544 seconds)
> {noformat}
> 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.



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