Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to create hive table with different columns as alias pointing to one column

Highlighted

How to create hive table with different columns as alias pointing to one column

New Contributor
 
1 REPLY 1
Highlighted

Re: How to create hive table with different columns as alias pointing to one column

Super Collaborator

Hi @Dinesh Singh,

If I understand correctly you need to select value which ever has non null out of two columns,

for instance if your data has this manner.

Col1Col2
A1B1
NULLB2
A3NULL

and you would like to select the data as (A1,B2,A3) you may use COALESCE(Col1,Col2,'<Your Default value>')

and on top of this table you may create a view so that end user directly view the result as single columns

NB: If you are convenient you may use case statement for complex logic implementation to retrieve as single column.

Thanks,

Don't have an account?
Coming from Hortonworks? Activate your account here