>>if I use calldate with cast operator it works: select * from table1 where 
>>cast(calldate as string) in ( '2014-08-11','2014-05-02'); 


As one other user, Tuong, suggested, it would be better to use cast in this 
following way:
select * from table1 where calldate in (
cast(    '2014-08-11' as date), cast('2014-05-02' as date));
This provides 2 benefits:
- correct semantic comparison for date values

- better performance as the cast is only done for the 2 literal values, not for 
every row of calldate


________________________________
 From: ilhami Kalkan <ilhami.kal...@intellica.net>
To: user@hive.apache.org 
Sent: Wednesday, August 13, 2014 6:03 AM
Subject: Re: hive query with in statement
 


Hi Kevin, 
I'm using 0.12 version and IN statement works fine except this
    situation:

select * from table1 where callhour in (1,2,3,4); --> success  
(callhour type: int)

select * from table1 where name in ('foo1','foo2','foo3','foo4');
    --> success
(name type: string)

select * from table1 where calldate = '2014-08-11'; --> success
(calldate type:date)

select * from table1 where calldate < '2014-08-11'; -->
    success
(calldate type:date)

select * from table1 where calldate in (
    '2014-08-11','2014-05-02');  -->error
(calldate type:date)

Error: Error while processing statement: FAILED: SemanticException
[Error 10014]: Line 1:38 Wrong arguments ''20014-03-02'': The
    arguments
for IN should be the same type! Types are: {date IN (string,
    string)}
(state=42000,code=10014)

if I use calldate with cast operator it works:
select * from table1 where cast(calldate as string) in (
    '2014-08-11','2014-05-02'); 




On 13-08-2014 15:49, Kevin Weiler wrote:

This is a relatively old stack overflow post. I’m not sure what version you 
guys are using, but IN seems to work just fine for me. 

--
Kevin Weiler
IT
 
IMC Financial Markets | 233 S. Wacker Drive, Suite 4300 | Chicago, IL 60606 | 
http://imc-chicago.com/
Phone: +1 312-204-7439 | Fax: +1 312-244-3301 | E-Mail: 
kevin.wei...@imc-chicago.com

On Aug 13, 2014, at 12:58 AM, Sreenath <sreenaths1...@gmail.com> wrote:

Hi, 
>
>
>hive doesn't support IN clause. you might want to check out 
>http://stackoverflow.com/questions/7677333/how-to-write-subquery-and-use-in-clause-in-hive
>
>
>
>On 12 August 2014 17:07, ilhami Kalkan <ilhami1...@hotmail.com> wrote:
>
>Hi all,
>>I have a problem with IN statement in HiveQL. My
                    table "cdr", column
>>"calldate" which type is "date". First query is
                    successfully return:
>>select * from cdr where calldate = '2014-05-02';
>>
>>But when query with IN statement,
>>
>>select * from cdr where calldate in (
                    '2014-08-11','2014-05-02');
>>
>>it returns below exception:
>>
>>Error: Error while processing statement: FAILED:
                    SemanticException
>>[Error 10014]: Line 1:38 Wrong arguments
                    ''20014-03-02'': The arguments
>>for IN should be the same type! Types are: {date IN
                    (string, string)}
>>(state=42000,code=10014)
>>
>>How can I handle this?
>>Thanks.
>>
>>Hive version 0.12
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
>
-- 
>
>Sreenath S Kamath 
>Bangalore
>Ph No:+91-9590989106

________________________________
 
The information in this e-mail is intended only for the person
        or entity to which it is addressed.

It may contain confidential and /or privileged material. If
        someone other than the intended recipient should receive this
        e-mail, he / she shall not be entitled to read, disseminate,
        disclose or duplicate it.

If you receive this e-mail unintentionally, please inform us
        immediately by "reply" and then delete it from your system.
        Although this information has been compiled with great care,
        neither IMC Financial Markets & Asset Management nor any of
        its related entities shall accept any responsibility for any
        errors, omissions or other inaccuracies in this information or
        for the consequences thereof, nor shall it be bound in any way
        by the contents of this e-mail or its attachments. In the event
        of incomplete or incorrect transmission, please return the
        e-mail to the sender and permanently delete this message and any
        attachments.

Messages and attachments are scanned for all known viruses.
        Always scan attachments before opening them.

Reply via email to