apachepig:limit在foreach引用顶级字段时,标量在输出中有多行

e0uiprwp  于 2021-06-24  发布在  Pig
关注(0)|答案(0)|浏览(229)

这个问题类似于两年前的一个问题,但是由于某种原因,它对我不起作用。实际上,这是标题中给出的两个想法(已回答的问题)的组合。下面的例子复制了公认的解决方案,但是它对我不起作用:我的错误是什么?我给出了一个完整的独立工作示例:
以下是数据:cat in_detail.csv

grp,val
1,2.1,
1,4.2,
1,6.3
2,6.5
2,1.2
2,4.3
2,3.2

cat in_cnt.csv
grp,cnt
1,2
2,3

预期输出(排序顺序不重要):

grp,val
1,2.1,
1,4.2,
2,6.5
2,1.2
2,4.3

下面是代码:带有错误消息

detail1    = LOAD '/tmp/sD_mvmd/c0nelha/data/in_detail.csv'   using PigStorage(',') as (grp:chararray,num:double);

cnt1       = LOAD  '/tmp/sD_mvmd/c0nelha/data/in_cnt.csv' using     

PigStorage(',') as (grp:chararray,cnt:int);

d_group = GROUP detail1 by (grp);

describe d_group;

--d_group: {group: chararray,detail1: {(grp: chararray,num: double)}}

describe cnt1;

--cnt1: {grp: chararray,cnt: int}

detail2 = JOIN d_group by (group), cnt1 by (grp);

describe detail2;

--detail2: {d_group::group: chararray,d_group::detail1: {(grp: chararray,num: double)},cnt1::grp: chararray,cnt1::cnt: int}

detail3 = FOREACH detail2 {

    mySelection   = LIMIT d_group::detail1 detail2.cnt1::cnt;

    GENERATE mySelection;
}

-- Apache Pig version 0.12.1.2.1.5.0-695 (rexported) compiled Aug 27 2014, 23:56:19

-- Backend error : Scalar has more than one row in the output.

-- 1st : (1,{(1,6.3),(1,4.2),(1,2.1)},1,2), 2nd :(2,{(2,3.2),(2,4.3),(2,1.2),(2,6.5)},2,3)

dump detail3;

暂无答案!

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

相关问题