添加额外的列到一个已经存在的列
Add extra columns to an already existing column
有没有办法向已经存在的 table 添加额外的列?例如,添加额外的列 user
,即所有行的 null
和列 date
设置为 2015-02-01
serial:long, title:chararray, year:int,score:float
(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)
grunt>
serial:long, title:chararray, year:int,score:float,user:long,date:chararray
(49586,Winter Wonderland,2013,2.8, ,2015-02-01 )
(49587,Top Gear: Series 19: Africa Special,2013,3.1, ,015-02-01 )
(49588,Fireplace For Your Home: Crackling Fireplace with Music,2010,7.3, ,015-02-01 )
你能试试这个吗?
输入
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)
有没有办法向已经存在的 table 添加额外的列?例如,添加额外的列 user
,即所有行的 null
和列 date
设置为 2015-02-01
serial:long, title:chararray, year:int,score:float
(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)
grunt>
serial:long, title:chararray, year:int,score:float,user:long,date:chararray
(49586,Winter Wonderland,2013,2.8, ,2015-02-01 )
(49587,Top Gear: Series 19: Africa Special,2013,3.1, ,015-02-01 )
(49588,Fireplace For Your Home: Crackling Fireplace with Music,2010,7.3, ,015-02-01 )
你能试试这个吗?
输入
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)