Skip to content
Advertisement

Hive Query to insert a value conditionally

I have a Table1 containing some blacklisted names. Now suppose I receive a record "def". The hive query should check if "def" is present in Table1 or not. If not the name_status should be set to blacklisted otherwise null. The name "def" will be inserted in both cases. The problem I am facing is that in hive we cannot use subquery in from clause only.

Table1

Table 2 (before receiveing "def")

Table 2 (after receiveing "def")

Table 2 (after receiveing "xyz")

Advertisement

Answer

Join with blacklist and use CASE to assign ‘blaclisted’ for joined rows

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement