[ 
https://issues.apache.org/jira/browse/HIVE-28901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17944419#comment-17944419
 ] 

Raghav Aggarwal commented on HIVE-28901:
----------------------------------------

After further debugging, the issue can be seen in a simple query like (check 
above q files for reference)

 
{code:java}
SELECT * from t1 where id = cast(474874000125288438 as string); {code}
in query plan, _{*}predicate:(UDFToDouble(id) = 4.7487400012528845E17D){*},_ 
both the bigint and string are converted to double compared before the value of 
*E* which is rounded off and giving wrong result for large number. 

*The join query is wrong.q is giving 2 rows (expected output) in Spark (3.4.1) 
and in mysql.* 

Here is the code which is converting string to DOUBLE:
[https://github.com/apache/hive/blob/master/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/TypeInfoUtils.java#L957-L959]

If I change it to LONG then it is working fine. _I understand for decimals, 
converting to LONG will result in loss of scale._ 

[~zabetak] , [~kkasa] , can you please provide your take on this? 

 

> Wrong query result for join between string and bigint
> -----------------------------------------------------
>
>                 Key: HIVE-28901
>                 URL: https://issues.apache.org/jira/browse/HIVE-28901
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Raghav Aggarwal
>            Assignee: Raghav Aggarwal
>            Priority: Major
>         Attachments: working.q, working.q.out, wrong.q, wrong.q.out
>
>
> Attaching the wrong and expected output q and q.out file to reproduce the 
> issue.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to