select count distinct using pig latin

前端 未结 3 1689
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-13 01:53

I need help with this pig script. I am just getting a single record. I am selecting 2 columns and doing a count(distinct) on another while also using a where like clause to find

3条回答
  •  梦毁少年i
    2021-02-13 02:30

    You could GROUP on each domain and then count the number of distinct elements in each group with a nested FOREACH syntax:

    D = group C by domain;
    E = foreach D { 
        unique_segments = DISTINCT C.segment;
        generate group, COUNT(unique_segments) as segment_cnt;
    };
    

提交回复
热议问题