nsledeski
nsledeski

Reputation: 37

Possible to set default value for column not matched in a join?

Say I'm running a Hive query with a left outer join to pull in a new column X from table B. Instead of having null values in column X for records in table A that weren't matched, is there a way to, say, default it to a string?

Upvotes: 0

Views: 1124

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270873

You do this using coalesce():

coalesce(b.x, 'default value')

This is an ANSI standard function and is supported in Hive.

Upvotes: 4

Related Questions