You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Zoltan Haindrich (JIRA)" <ji...@apache.org> on 2017/10/07 12:23:00 UTC

[jira] [Commented] (HIVE-17726) Using exists may lead to incorrect results

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

Zoltan Haindrich commented on HIVE-17726:
-----------------------------------------

Seems like this problem arises from the fact the {{exists}} is somewhere translated into an {{inner}} join.

At least this seems to be the problem to me at this point:
https://github.com/apache/hive/blob/caf3330330c9c8c5fc922f3186ddeab4266b60bb/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java#L8873

I think the correct join type would be {{leftsemi}} for these cases.

> Using exists may lead to incorrect results
> ------------------------------------------
>
>                 Key: HIVE-17726
>                 URL: https://issues.apache.org/jira/browse/HIVE-17726
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 3.0.0
>            Reporter: Zoltan Haindrich
>
> {code}
> drop table if exists tx1;
> create table tx1 (a integer,b integer);
> insert into tx1	values  (1, 1),
>                         (1, 2),
>                         (1, 3);
> select count(*) as result,3 as expected from tx1 u
> where exists (select * from tx1 v where u.a=v.a and u.b <> v.b);
> select count(*) as result,3 as expected from tx1 u
> where exists (select * from tx1 v where u.a=v.a and u.b <> v.b limit 1);
> {code}
> current results are 6 and 2.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)