Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> Can we pass tuple value in macro?


Copy link to this message
-
Can we pass tuple value in macro?
Hi,

I have this function which I am using for different group by fields, can I
call this macro like

calculate_sum(A,$0)
calculate_sum(A,($0,$1))
calculate_sum(A,($0,$1,$2))

define calculate_sum ( A, groupByField)
returns A_SUM1 {
        A_SUM = group $A by $groupByField;
        $A_SUM1 = foreach A_SUM generate FLATTEN(group),SUM($A.spend) as
spend,SUM($A.units) as units ;
        };

Thanks,

Deepak