Created 03-15-2017 09:41 AM
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
Created 03-15-2017 10:51 AM
@Gnanasekaran G Use the following ( <=>) operator instead of (=) operator
SELECT CASE WHEN (NULL<=>NULL) THEN "equals" ELSE "not equals" end AS value;
Reference:
Created 03-16-2017 04:58 AM
@Gnanasekaran G if this helped, please vote/accept best answer. we can close the thread
Created 03-15-2017 11:55 PM
(NULL=NULL) is neither true nor false it will evaluate to NULL/UNKNOWN. (reference https://www.simple-talk.com/sql/learn-sql-server/sql-and-the-snare-of-three-valued-logic/)
As pointed by @Murali Ramasami above you should use <=> operator if you would like null=null evaluate to true.