title: How to use over function in piggybank
body: <p>I'm new to Apache pig and cannot figure out what goes wrong for the cumulative calculation using Over function of piggybank. I would like the cumulative salary over each period given the same business and location for the following data: </p>
  
  <pre><code>business|location|period|salary
  --------+--------+------+-------
  100     |  East  |   1  |  100
  100     |  East  |   1  |  55
  100     |  East  |   2  |  100
  100     |  East  |   3  |  150
  100     |  West  |   1  |  150
  100     |  West  |   2  |  200
  100     |  West  |   3  |  250
  200     |  East  |   1  |  50
  200     |  East  |   2  |  50
  200     |  East  |   3  |  50
  200     |  West  |   1  |  80
  200     |  West  |   2  |  100
  200     |  West  |   3  |  120
  </code></pre>
  
  <p>The result I'm looking for is:</p>
  
  <pre><code>business|location|period|cumulative salary
  --------+--------+------+---------------
    100   |  East  |  1   |    155
    100   |  East  |  2   |    255
    100   |  East  |  3   |    405
    100   |  West  |  1   |    150
    100   |  West  |  2   |    350
    100   |  West  |  3   |    600
    200   |  East  |  1   |    50
    200   |  East  |  2   |    100
    200   |  East  |  3   |    150
    200   |  West  |  1   |    80
    200   |  West  |  2   |    180
    200   |  West  |  3   |    300
  </code></pre>
  
  <p>According to this Over doc, I should be able to do it by</p>
  
  <pre><code>REGISTER /opt/mapr/pig/pig-0.12/contrib/piggybank/java/piggybank.jar;
  A = LOAD '/user/sliang/pig/testData' USING PigStorage(',') as (business:long, location:chararray, period:long, salary:long);
  B = group A by (business, location);
  C = foreach B {
      C1 = order A by period;
      generate flatten(Stitch(C1, Over(C1.salary, 'sum(long)')));
  };
  D = foreach C generate business, location, period, $9;
  </code></pre>
  
  <p>But I got error start at C: </p>
  
  <pre><code>[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve Stitch using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]
  </code></pre>
  
  <p>I googled but there is not much info regarding this... I also checked the jar with other piggybank function and it works, so I guess it's not because piggybank is not correctly registered. I'm using pig 0.12 version.</p>
  
  <p>Any help is greatly appreciated. Thank you!</p>