presto: != operator is not working correctly in presto for decimal values
I connected hive with presto and query a table containing decimal values. In case of != operator it’s showing me all the rows of the table.
Below are the create table and load queries for hive:
create table decimalOperatorCheck(name String, ids decimal(10,2))ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
Load data:
load data local inpath '/home/hduser/Files/decimaldata.csv' into table decimalOperatorCheck;
Query in Presto CLI:
select * from decimaloperatorcheck where ids !=12345.56;
Output:
presto:default> select * from decimaloperatorcheck where ids !=12345.56; name | ids
--------±--------- Justin | 11.90
Josh | 233.34
Alex | 123.45
Ryan | 12345.56 (4 rows)
Here is the csv used for loading data. data.txt
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (16 by maintainers)
Actually this is not strictly decimal related. It is implication of three facts:
12345.56) are interpreted in Presto as literals of typeDOUBLEDECIMALandDOUBLEtype the comparison is happening inDOUBLEdomain (the decimal value is first cast toDOUBLE).DOUBLESo the query
is effectively executing as:
If you explicitly rewrite query so it is happening in
DECIMALdomain using appropriate literal constructor the query will hopefully pass:We have plans straightening that up but it is somewhat larger effort. So far pushed out of the priority queue.
I think so. Followup from #8409 is still valid, yet it is not related to this issue.