title: Pig: What is the correct syntax to flatten a nested bag (2-levels deep)
body: <p>I'm loading this data:</p>
  
  <pre><code>data6 = 'item1' 111 { ('thing1', 222, {('value1'),('value2')}) }
  </code></pre>
  
  <p>Using this command</p>
  
  <pre><code>A = load 'data6' as ( item:chararray, d:int, things:bag{(thing:chararray, d1:int, values:bag{(v:chararray)})} );
  </code></pre>
  
  <p>I'm attempting to flatten the whole thing this command.</p>
  
  <pre><code>A_flattened = FOREACH A GENERATE item, d, things::thing AS thing; things::d1 AS d1, FLATTEN(things::values) AS value;
  </code></pre>
  
  <p>But I just get this error:</p>
  
  <pre><code>Invalid field projection. Projected field [things::thing] does not exist in schema: item:chararray,d:int,things:bag{:tuple(thing:chararray,d1:int,values:bag{:tuple(v:chararray)})}
  </code></pre>
  
  <p>I tried naming the inner <code>things</code> tuple, but I get a similar error. Can someone help me with the right syntax here?</p>