如何在PIG中使用某些硬编码值连接变量
A = LOAD'data'为(f1:chararray,f2:chararray,f3:chararray);
X =对于一个生成的CONCAT(“BIG”,f3);
预期产出:
(apache的,开放的,BIGsource)
(hadoop的,地图,BIGreduce)
(猪,猪,BIGlatin)
答案 0 :(得分:1)
Pig不支持双引号,因此您需要将硬编码值从双引号更改为单引号。
X = FOREACH A GENERATE f1,f2,CONCAT('BIG',f3);
<强>更新强>
您可以使用REPLACE
函数从输入中删除双引号
示例如下
数据强>
"apache","open","source"
"hadoop","map","reduce"
"pig","pig","latin"
<强> PigScript:强>
A = LOAD 'data' USING PigStorage(',') AS (f1:chararray, f2:chararray, f3:chararray);
B = FOREACH A GENERATE REPLACE(f1,'"',''),REPLACE(f2,'"',''),CONCAT('BIG',REPLACE(f3,'"',''));
DUMP B
<强>输出:强>
(apache,open,BIGsource)
(hadoop,map,BIGreduce)
(pig,pig,BIGlatin)