title: Converting tuple of bags to Multiple tuples in pig using a java UDF
body: <p>I have my data as: </p>
  
  <pre><code>{(2000),(1800),(2700)}
  {(2014),(1500),(1900)} etc.
  </code></pre>
  
  <p>I have created a java UDF:</p>
  
  <pre><code>DataBag bag = (DataBag) top3.get(0);
  Tuple categoryCode = null;
  if(bag.size() == 0)
      return null;
  for(Iterator&lt;Tuple&gt; code=bag.iterator(); code.hasNext();)
      categoryCode=code.next();
  return categoryCode.get(0).toString();
  </code></pre>
  
  <p>I want my output to be like:  </p>
  
  <pre><code>2000,1800,2700
  2014,1500,1900 etc
  </code></pre>
  
  <p>My UDF gives me the output as:  </p>
  
  <pre><code>2000
  2014 etc
  </code></pre>
  
  <p>Please help whether there is some other solution for this. Please help with your inputs. </p>