You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Deepak Khandelwal <dk...@gmail.com> on 2017/08/23 22:11:47 UTC

One column into multiple column.

Can someone tell the best way to implement below in hive.

 how can we take input from column c1 from tab Such that c1 has multiple
values delimited by pipe. Each of the delimited value from col c1 of table
t1 needs to be inserted into separate column in table t2.

I can write a UDF for this but this udf I have to call 10 times to retrieve
10 delimited values from c1 of table t1 and then insert them into 10
separate cols of table t2. I am just trying to find out if there is a
better way to do this so that I don't have to call udf 10 times
 Thanks

Re: One column into multiple column.

Posted by Furcy Pin <fu...@flaminem.com>.
Hello,

You can use the split(string, pattern) UDF, that returns an array.
You can compute this array in a subquery, and then assign a[0], a[1], a[2]
... to each column.
The split UDF will only be called once per row.



On Thu, Aug 24, 2017 at 12:11 AM, Deepak Khandelwal <
dkhandelwal.tia@gmail.com> wrote:

> Can someone tell the best way to implement below in hive.
>
>  how can we take input from column c1 from tab Such that c1 has multiple
> values delimited by pipe. Each of the delimited value from col c1 of table
> t1 needs to be inserted into separate column in table t2.
>
> I can write a UDF for this but this udf I have to call 10 times to
> retrieve 10 delimited values from c1 of table t1 and then insert them into
> 10 separate cols of table t2. I am just trying to find out if there is a
> better way to do this so that I don't have to call udf 10 times
>  Thanks
>