Thursday, 15 May 2014

apache pig - Pig: how to loop through all fields/columns? -



apache pig - Pig: how to loop through all fields/columns? -

i'm new pig. need calculation fields/columns in table. however, can't find way searching online. great if here can give help!

for example: have table 100 fields/columns, of them numeric. need find average of each field/column, there elegant way without repeat average(column_xxx) 100 times?

if there's 1 or 2 columns, can do

b = grouping all; c = foreach b generate average(column_1), average(columkn_2);

however, if there's 100 fields, it's tedious repeatedly write average 100 times , it's easy have errors.

one way can think of embed pig in python , utilize python generate string , set compile. however, still sounds weird if works.

thank in advance help!

apache-pig

No comments:

Post a Comment