title: Sum multiple columns using PIG
body: <p>I have multiple files with same columns and I am trying to aggregate the values in two columns using SUM.</p>
  
  <p>The column structure is below</p>
  
  <pre><code>ID first_count second_count name desc
  1  10          10           A    A_Desc
  1  25          45           A    A_Desc
  1  30          25           A    A_Desc
  2  20          20           B    B_Desc
  2  40          10           B    B_Desc
  </code></pre>
  
  <p>How can I sum the first_count and second_count?</p>
  
  <pre><code>ID first_count second_count name desc
  1  65          80           A    A_Desc
  2  60          30           B    B_Desc
  </code></pre>
  
  <p>Below is the script I wrote but when I execute it I get an error "Could not infer matching function for SUM as multiple of none of them fit.Please use an explicit cast.</p>
  
  <pre><code>A = LOAD '/output/*/part*' AS (id:chararray,first_count:chararray,second_count:chararray,name:chararray,desc:chararray);
  B = GROUP A BY id;
  
  C = FOREACH B GENERATE group as id,
                SUM(A.first_count) as first_count,
                SUM(A.second_count) as second_count,
                A.name as name,
                A.desc as desc;
  </code></pre>