错误:将生成的元组传递给pig latin中的groupby函数

时间:2016-01-26 08:48:23

标签: tuples apache-pig

'data'文件看起来像

Column1 | Y
Column2 | N
Column3 |Y
Column4| Y
Column5|N

grunt> DATA = LOAD 'data' USING PigStorage('|') as (groupBy:chararray ,
condition :chararray);

grunt> FILTERED = FILTER DATA BY condition == 'Y';

grunt> GROUPED = GROUP FILTERED BY condition;

grunt> TUPLED = foreach GROUPED generate
FLATTEN(BagToTuple(FILTERED.groupBy));

grunt> describe TUPLED;

TUPLED: {org.apache.pig.builtin.bagtotuple_482::groupBy: chararray}

grunt> dump TUPLED;

(Column1,Column3,Column4)

当我尝试将此TUPLED传递给按功能分组时 低于错误 cfl.txt输入文件数据

cfl_code | book_code | COUNTRY_CODE | START_DATE |结束日期| cfl_type |量 CFL_0001 | 159 |美| 2015年1月1日| 2015年1月2日| I | 100 CFL_0001 | 159 |美| 2015年1月1日| 2015年1月2日| N | 1200 CFL_0002 | 159 |阿联酋| 2015年1月1日| 2015年1月3日| I | 200 CFL_0002 | 159 | US | 2015-01-01 | 2015-01-03 | N | 2400

grunt> Load_cfl = LOAD '/user/hdfs/pig/data/cfl.txt' USING PigStorage('|') as (cfl_code:chararray,book_code:int,currency_code:chararray,start_date:datetime,end_date:datetime,cfl_type:chararray,amount:double );
grunt> grouped_data = group Load_cfl by (TUPLED);
2016-01-26 02:56:48,871 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: Pig script failed to parse:
<line 7, column 34> Invalid scalar projection: TUPLED : A column needs to be projected from a relation for it to be used as a scalar
Details at logfile: /home/hdfs/pig_1453794921782.log

0 个答案:

没有答案