Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

count()

Returns the number of rows that match the query criteria.
For example, to calculate the number of carriers:
1q = foreach q generate 'carrier' as 'carrier', count() as 'count';
count() operates on the stream that is input to the group or cogroup statement. It doesn’t operate on the newly grouped stream or on an ungrouped stream.
1q = load "Carriers";
2q = group q by (Year);
3q = foreach a1 generate count(q) as countYear, count() as count, Year as year;