title: Print limited number of elements in collect_set array using printf function
body: <p>I want to <code>printf()</code> just the first 3 patients in <code>collect_set()</code> of patient numbers.</p>
  
  <p><strong>A</strong>.  I have created "patient_list" using collect_set</p>
  
  <pre><code>collect_set(distinct patient_seq) AS patient_list
  </code></pre>
  
  <p>which yields arrays of patients numbers of varying length (4, 5 or 6 digits)</p>
  
  <p>Example:</p>
  
  <pre><code>["16189","26599","406622","419117","5551"]
  ["223587","224663","232072","326504","433430","436673","54540","58188","74118"]
  </code></pre>
  
  <p><strong>B</strong>.  I then stripped out the commas and quotes and separated by '*' (in order to grab just the first 3 patients, in the next step):</p>
  
  <pre><code>concat_ws('*', patient_list) AS pat_list
  </code></pre>
  
  <p>This produces:</p>
  
  <pre><code>16189*26599*406622*419117*5551
  223587*224663*232072*326504*433430*436673*54540*58188*74118
  </code></pre>
  
  <p><strong>C</strong>.  I tried to use <code>SUBSTRING_INDEX()</code> to create a new variable (pat_list_short) containing just the first 3 patients, <strong>but this function is not supported in hive 1.1.0</strong> (not supported until 1.3.0).</p>
  
  <pre><code>substring_index(pat_list, '*', 3) AS pat_list_short
  </code></pre>
  
  <p>What other option do I have?</p>
  
  <p>I want to feed the pat_list_short into the PRINTF using %s  in order to print out just the first three patient numbers for review team.  Since the patient num varies in length I can't just limit the print to a certain length</p>
  
  <p>Thanks</p>