将额外列添加到现有列

时间:2015-03-19 17:23:48

标签: hadoop apache-pig

有没有办法在现有表中添加额外的列?例如,为所有行添加额外列usernull列设置为date

2015-02-01

1 个答案:

答案 0 :(得分:0)

你能试试吗?

<强>输入

49586,Winter Wonderland,2013,2.8
49587,Top Gear: Series 19: Africa Special,2013,3.1
49588,Fireplace For Your Home: Crackling Fireplace with Music,2010,7.3

<强> PigScript:

A = LOAD 'input' USING PigStorage(',') AS (serial:long,title:chararray,year:int,score:float);
B = FOREACH A GENERATE serial,title,year,score, null AS (user:long) ,'2015-02-01' AS (date:chararray);
DUMP B;

<强>输出:

(49586,Winter Wonderland,2013,2.8,,2015-02-01)
(49587,Top Gear: Series 19: Africa Special,2013,3.1,,2015-02-01)
(49588,Fireplace For Your Home: Crackling Fireplace with Music,2010,7.3,,2015-02-01)