Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Hive Null comparison not works properly

avatar
New Member

Hi,

I have below Hive query and its not giving me "equals" as output. Why?

hive> select case when (NULL=NULL) then "equals" else "not equals" end as value;
OK
not equals
1 ACCEPTED SOLUTION

avatar
Rising Star

@Gnanasekaran G Use the following ( <=>) operator instead of (=) operator

SELECT CASE WHEN (NULL<=>NULL) THEN "equals" ELSE "not equals" end AS value;

Reference:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-RelationalOper...

View solution in original post

5 REPLIES 5

avatar
Super Collaborator
@Gnanasekaran G

check NULL is NULL instead of NULL = NULL. This worked for me.

avatar
Rising Star

@Gnanasekaran G Use the following ( <=>) operator instead of (=) operator

SELECT CASE WHEN (NULL<=>NULL) THEN "equals" ELSE "not equals" end AS value;

Reference:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-RelationalOper...

avatar
Rising Star

@Gnanasekaran G if this helped, please vote/accept best answer. we can close the thread

avatar
New Member

Thank you @Murali Ramasami @Sharmadha Sainath . It works for me now.

avatar
Rising Star

Thanks @Gnanasekaran G please accept best answer. we can close the thread