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

gk7wooem  于 2021-06-21  发布在  Pig
关注(0)|答案(0)|浏览(148)

“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)

当我试图通过groupby函数传递这个元组时,得到下面的错误cfl.txt输入文件数据
cfl\U编码| cfl\U编码| cfl\U编码| cfl\U编码| cfl\U编码| cfl\U编码|邮政编码|书籍| U编码|邮政编码|国家|国家代码|开始日期结束日期cfl类型| cfl金额| cfl金额|金额|金额| cfl | U U U 0001 |金额|金额| |金额|金额|金额美国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

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题