خرید بک لینک

Vote count: 0

Need to count the # of users in each group, and group allocation for each user is based on their payment they made. Here is my current code, wondering if any ways to make it more elegant? Is it possible to complete the logic by one group by statement? Thanks.

customer_group = group clicks by customerID;
customer_payment_count=foreach customer_group generate customerID, COUNT(payments) as payment_amount;
tier1 = filter customer_payment_count by payment_amount <= 2;
tier2 = filter customer_payment_count by 3 <= payment_amount <= 5;
tier3 = filter customer_payment_count by payment_amount > 5;
tier1_group = group tier1 by all;
tier1_count = foreach tier1_group generate COUNT_STAR(tier1);
tier2_group = group tier2 by all;
tier2_count = foreach tier2_group generate COUNT_STAR(tier2);
tier3_group = group tier3 by all;
tier3_count = foreach tier3_group generate COUNT_STAR(tier3);
result = UNION tier1_count, tier2_count, tier3_count;

thanks in advance, Lin

asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 9 اسفند 1394 ساعت: 9:44

صفحه بندی