Skip to content
Advertisement

Hive – How to read a column from a table which is of type list

I have a Hive table named customer, which has a column named cust_id of list type, with following values: cust_id

Now I want to read only this specific column cust_id in my select query, which can give all these list values as following separate values of this column cust_id:

Basically I want to fetch all the values of cust_id from this table as one column, to use these values in the where exists or where in clause of my other query. A solution for this would be highly appreciated.

Advertisement

Answer

AFAIK this is what you are looking for from hive manual..

Lateral view is used in conjunction with user-defined table generating functions such as explode(). As mentioned in Built-in Table-Generating Functions, a UDTF generates zero or more output rows for each input row.

for example

Full example :

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