Quantcast
Channel: PIG how to count a number of rows in alias - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Answer by Igor Katkov for PIG how to count a number of rows in alias

$
0
0

Here is a version with optimization. All the solutions above would require pig to read and write full tuple when counting, this script below just write '1'-s

DEFINE row_count(inBag, name) RETURNS result {    X = FOREACH $inBag generate 1;    $result = FOREACH (GROUP X ALL PARALLEL 1) GENERATE '$name', COUNT(X);};

The use it like

xxx = row_count(rows, 'rows_count');

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>