[Solved-1 Solution] Hadoop Pig count number ?
What is count()
- The COUNT() function of Pig Latin is used to get the number of elements in a bag. While counting the number of tuples in a bag, the COUNT() function ignores (will not count) the tuples having a NULL value in the FIRST FIELD.
- Given below is the syntax of the COUNT() function.
What's the effective way to count number in Pig?
- Two things. Firstly, count should actually be COUNT . In pig, all builtin functions should be called with all-caps.
- Secondly, COUNT counts the number of values in a bag, not for a value. Therefore, we should group by true/false, then COUNT:
- If we want the counts of true and false in their own relations then we can FILTER the output of counts. However, it would probably be better to SPLIT boolean, then do two separate counts: