title: Apache Spark group by DF, collect values into list and then group by list
body: <p>I have the following Apache Spark DataFrame (<strong>DF1</strong>):</p>
  
  <pre><code>function_name | param1 | param2 | param3 | result
  ---------------------------------------------------
       f1       |   a    |   b    |   c    |   1        
       f1       |   b    |   d    |   m    |   0
       f2       |   a    |   b    |   c    |   0
       f2       |   b    |   d    |   m    |   0
       f3       |   a    |   b    |   c    |   1
       f3       |   b    |   d    |   m    |   1
       f4       |   a    |   b    |   c    |   0
       f4       |   b    |   d    |   m    |   0
  </code></pre>
  
  <p>First of all, I'd like to group DataFrame by <code>function_name</code>, collect results into the <code>ArrayType</code> and receive the new DataFrame (<strong>DF2</strong>):</p>
  
  <pre><code>function_name | result_list
  --------------------------------
       f1       |  [1,0]
       f2       |  [0,0]
       f3       |  [1,1]
       f4       |  [0,0]
  </code></pre>
  
  <p>rigth after that, I need to collect <code>function_name</code> into <code>ArrayType</code> by grouping <code>result_list</code> and I'll receive new DataFrame like the following (<strong>DF3</strong>):</p>
  
  <pre><code>result_list |  function_name_lists
  ------------------------------------
      [1,0]   |   [f1]
      [0,0]   |   [f2,f4]
      [1,1]   |   [f3]
  </code></pre>
  
  <p>So, I have a question  - first of all, can I use grouping by ArrayType column in Apache Spark? If so, I can potentially have tens of millions values in <code>result_list</code> ArrayType single field. Will Apache Spark be able to group by <code>result_list</code> column in this case?</p>