Saturday, 24 December 2022

Hive: coalesce: Return first non-null value

Signature

coalesce(value1,value2,...)

 

Return first non-null value from the given values. If all the values are null, then it return null.

hive> SELECT coalesce('Krishna', null, null);
OK
_c0
Krishna
Time taken: 0.042 seconds, Fetched: 1 row(s)
hive> ;
hive> ;
hive> SELECT coalesce(null, 'Ram', 'Krishna', null, null);
OK
_c0
Ram
Time taken: 0.05 seconds, Fetched: 1 row(s)
hive> ;
hive> ;
hive> SELECT coalesce(null, null, null);
OK
_c0
NULL
Time taken: 0.039 seconds, Fetched: 1 row(s)

 


Previous                                                    Next                                                    Home

No comments:

Post a Comment