关闭

Pig的一个小问题 (filter之后 没有数据)

标签: pig
362人阅读 评论(0) 收藏 举报
分类:


写Pig的时候,如果需要对数据中某个字段进行 比较或者运算,尤其是使用Filter的时候。

该字段最好是 bytearray类型,而不要用 int 或者 chararray类型。否则得不到数据


--抽取话单文件中过程号为 attach的话单 统计
set job.name 'lte_kpi_user_analysis_s1mme_attatch_15min';

allData = load '/user/hdfs/data/200506/20050601/000000/0B43CED07C7438B4328F918C64DACE35-merge';


sel_fields = foreach allData generate  FLOOR($10/300)*300+8*3600 as  (time:chararray), $2 as (interface_type:chararray),$8 as (procedure_type:bytearray

,$7 as (msisdn:chararray),$6 as (imei:chararray),$5 as (imsi:chararray),$1 as (city:chararray),$21 as (mme_ip:chararray),$22 as (enodeb_ip:chararray)

,$25 as (tac:chararray),$26 as (cell_id:chararray),$12 as (cause:int),($10-$9) as  (delay:int),$11 as (procedure_status:bytearray);


--抽取过程号等于1 

s1mme_attach = filter sel_fields by procedure_type == 1;


group_by_user = group s1mme_attach by(time, interface_type, procedure_type, msisdn,imei, imsi, city,mme_ip,
   
   enodeb_ip, tac, cell_id, cause, hour,miniute15);
   

tmp_result = foreach group_by_user {
   
  failures = filter s1mme_attach by procedure_status>0;
   
   user_num = distinct s1mme_attach.imsi;
   
   generate FLATTEN(group), COUNT(failures) as count_fail, COUNT(user_num) as count_total, AVG(s1mme_attach.delay);
   
};

--测试输出

filter_tmp = limit s1mme_attach 10;

test_out = limit group_by_user 10;

test_out2 = limit tmp_result 10;

store  filter_tmp into  '/user/hdfs/xiatao/pigOutput/s1mme_attatch_15min_filter1';

store test_out into '/user/hdfs/xiatao/pigOutput/s1mme_attatch_15min_1';

store test_out2 into '/user/hdfs/xiatao/pigOutput/s1mme_attatch_15min_2';

如果不适用 bytearray类型,后面输出的几个文件夹中就没有数据。

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:123983次
    • 积分:2016
    • 等级:
    • 排名:第19878名
    • 原创:64篇
    • 转载:36篇
    • 译文:5篇
    • 评论:13条
    博客专栏
    最新评论