You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by Bhavesh Shah <bh...@gmail.com> on 2012/04/11 14:59:52 UTC

Does Hive supports EXISTS keyword in select query?

Hello all,
I want to query like below in Hive:
Select a.* FROM tblA a JOIN tblB b ON a.field1 = b.field1
where (a.field2 is null or not exists(select field2 from tblB where filed2
is not null)

But I think Hive doesn't supports EXISTS keyword so how can I overcome this
issue?
Pls suggest me some solution to this. I just got this kind of situation
where I need to implement some thing like EXISTS/NOT EXISTS



-- 
Thanks and Regards,
Bhavesh Shah

RE: Does Hive supports EXISTS keyword in select query?

Posted by "Hezhiqiang (Ransom)" <ra...@huawei.com>.
SEMI is only for exist.
Maybe you can try this 
 Select a.* FROM tblA a left outer JOIN tblB b ON a.field1 = b.field1 where a.field2 is null or b.fild2 is null


Best regards
Ransom.

-----Original Message-----
From: Philip Tromans [mailto:philip.j.tromans@gmail.com] 
Sent: Wednesday, April 11, 2012 9:02 PM
To: user@hive.apache.org
Subject: Re: Does Hive supports EXISTS keyword in select query?

Hi,

Hive supports EXISTS via SEMI JOIN. Have a look at:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Joins

Cheers,

Phil.

On 11 April 2012 13:59, Bhavesh Shah <bh...@gmail.com> wrote:
> Hello all,
> I want to query like below in Hive:
> Select a.* FROM tblA a JOIN tblB b ON a.field1 = b.field1
> where (a.field2 is null or not exists(select field2 from tblB where filed2
> is not null)
>
> But I think Hive doesn't supports EXISTS keyword so how can I overcome this
> issue?
> Pls suggest me some solution to this. I just got this kind of situation
> where I need to implement some thing like EXISTS/NOT EXISTS
>
>
>
> --
> Thanks and Regards,
> Bhavesh Shah
>

Re: Does Hive supports EXISTS keyword in select query?

Posted by Philip Tromans <ph...@gmail.com>.
Hi,

Hive supports EXISTS via SEMI JOIN. Have a look at:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Joins

Cheers,

Phil.

On 11 April 2012 13:59, Bhavesh Shah <bh...@gmail.com> wrote:
> Hello all,
> I want to query like below in Hive:
> Select a.* FROM tblA a JOIN tblB b ON a.field1 = b.field1
> where (a.field2 is null or not exists(select field2 from tblB where filed2
> is not null)
>
> But I think Hive doesn't supports EXISTS keyword so how can I overcome this
> issue?
> Pls suggest me some solution to this. I just got this kind of situation
> where I need to implement some thing like EXISTS/NOT EXISTS
>
>
>
> --
> Thanks and Regards,
> Bhavesh Shah
>