title: USING Filter in a Nested FOREACH in PIG
body: <p>I have two pig relations. The first one <code>count_pairs</code> shows pairs of words and how many times they were seen. ex <code>((car,tire), 4)</code>. The second is <code>word_counts</code>, which keeps track of how many times each word was seen ex. <code>(car, 20)</code>. I would like to find the percentage of how many times each pair was seen compared to how many times just the first word was seen. In our case I would want <code>((car,tire), 4/20)</code>. I tried to write a nested foreach to solve this problem :</p>
  
  <pre><code>&gt; percent_count_pairs = FOREACH count_pairs {
  &gt; denom = FILTER word_counts BY ($0 ==count_pairs.pair.word1);
  &gt; GENERATE pair, count2/(double)denom.$1;}
  </code></pre>
  
  <p>I keep getting this error: </p>
  
  <pre><code>'Pig script failed to parse: 
  &lt;file src/cluster.pig, line 27, column 15&gt; expression is not a project expression: (Name: ScalarExpression) Type: null Uid: null)'
  </code></pre>
  
  <p>This point to the line with the <code>FILTER</code>; 
  googling this error did not lead me to anything helpful. Please help! 
  (ps. this does work if I take the line with <code>FILTER</code> out of the foreach...)</p>