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

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

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

  1. grp,val
  2. 1,2.1,
  3. 1,4.2,
  4. 1,6.3
  5. 2,6.5
  6. 2,1.2
  7. 2,4.3
  8. 2,3.2
  9. cat in_cnt.csv
  10. grp,cnt
  11. 1,2
  12. 2,3

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

  1. grp,val
  2. 1,2.1,
  3. 1,4.2,
  4. 2,6.5
  5. 2,1.2
  6. 2,4.3

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

  1. detail1 = LOAD '/tmp/sD_mvmd/c0nelha/data/in_detail.csv' using PigStorage(',') as (grp:chararray,num:double);
  2. cnt1 = LOAD '/tmp/sD_mvmd/c0nelha/data/in_cnt.csv' using
  3. PigStorage(',') as (grp:chararray,cnt:int);
  4. d_group = GROUP detail1 by (grp);
  5. describe d_group;
  6. --d_group: {group: chararray,detail1: {(grp: chararray,num: double)}}
  7. describe cnt1;
  8. --cnt1: {grp: chararray,cnt: int}
  9. detail2 = JOIN d_group by (group), cnt1 by (grp);
  10. describe detail2;
  11. --detail2: {d_group::group: chararray,d_group::detail1: {(grp: chararray,num: double)},cnt1::grp: chararray,cnt1::cnt: int}
  12. detail3 = FOREACH detail2 {
  13. mySelection = LIMIT d_group::detail1 detail2.cnt1::cnt;
  14. GENERATE mySelection;
  15. }
  16. -- Apache Pig version 0.12.1.2.1.5.0-695 (rexported) compiled Aug 27 2014, 23:56:19
  17. -- Backend error : Scalar has more than one row in the output.
  18. -- 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)
  19. dump detail3;

暂无答案!

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

相关问题