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.

Don't we have a way to select normal column along with UDTF in hive??

Solved Go to solution

Don't we have a way to select normal column along with UDTF in hive??

Rising Star

I would like to select one normal datatype column(primitive) column along with UDTF as follows.But it is throwing error like

SemanticException [Error 10081]: UDTF's are not supported outside the SELECT clause, nor nested in expressions

I understood the problem.Don't we have any way to do this.

Query is : select col1,explode(split(col2,'\\s')) from table_name;

assume col2 is int type and col2 is string.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Don't we have a way to select normal column along with UDTF in hive??

@Suresh Bonam

You have to use LATERAL VIEW to do it.

See this:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+LateralView

And an example here:

  select s.code, exp.splitted
  from sample_07 s
  lateral view explode(split('asdfa adsfa asdaf asdfad','\\s')) exp as splitted

View solution in original post

2 REPLIES 2
Highlighted

Re: Don't we have a way to select normal column along with UDTF in hive??

@Suresh Bonam

You have to use LATERAL VIEW to do it.

See this:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+LateralView

And an example here:

  select s.code, exp.splitted
  from sample_07 s
  lateral view explode(split('asdfa adsfa asdaf asdfad','\\s')) exp as splitted

View solution in original post

Highlighted

Re: Don't we have a way to select normal column along with UDTF in hive??

Rising Star

@Guilherme Braccialli thank you.its working.

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