For form file
AB user1 CD user2 AD user3 AD user1
I want to calculate the counter of various values of field 3, i.e. count(distinct(user1, user2,user2,user1)) = 3
I do this using the following pig script
A = load 'myTestData' using PigStorage('\t') as (a1,a2,a3); user_list = foreach A GENERATE $2; unique_users = DISTINCT user_list; unique_users_group = GROUP unique_users ALL; uu_count = FOREACH unique_users_group GENERATE COUNT(unique_users); store uu_count into 'output';
Is there a better way to get the number of different field values?
Netra m
source share