Parsa Parsa - 1 year ago 315
SQL Question


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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download