Parsa Parsa - 3 months ago 81
SQL Question

COALESCE with Hive SQL

Since there's 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 this 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?

Answer

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