Categories
hive sql

COALESCE with Hive SQL

Since there is no IFNULL, ISNULL, or NVL function supported on Hive, I’m having trouble converting NULL to 0. I tried COALESCE(*column name*, 0) but received the below error message:

Argument type mismatch 0: The expressions after COALESCE should all
have the same type: “bigint” is expected but “int” is found

How to resolve this?

As Lamak pointed out in the comment, COALESCE(column, CAST(0 AS BIGINT)) resolves the error.