Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a column to an already existing table in apache pig

I already have a table created using Pig. Now I want to add a random number with every row(record) to give me a new table with this added column.

Is this possible and how ?

like image 211
sammyiitkgp Avatar asked Nov 02 '22 14:11

sammyiitkgp


1 Answers

You may use the RANDOM UDF for this purpose.
E.g:

A = ...
B = foreach A generate (int)(RANDOM()*100.0) as rnd, [other fields...]
like image 146
Lorand Bendig Avatar answered Nov 15 '22 07:11

Lorand Bendig