title: How to pass two-dimensional array to User defined functions?
body: <p>Using UDF implies that each factor <code>c1</code>, <code>c2</code>, <code>c3</code> must be passed by parameter independently. Is there any flexible solution, e.g. how to pass a sequence of these factors to <strong>UDF</strong>?</p>
  
  <pre><code>val myFunction = udf {
        (userBias: Float, productBias: Float, productBiases: Map[Long, Float],
          userFactors: Seq[Float], productFactors: Seq[Float], c1: String, c2: String, c3: String) =&gt;
  
          var result = Float.NaN
  
          // result calculation
  
          result
      }
  </code></pre>
  
  <p>And then I call this function the following way (<code>dataset</code> is a <code>DataFrame</code>):</p>
  
  <pre><code>myFunction(userBias("bias"), 
             productBias("bias"),
             productBias("biases"),
             userFactors("features"), 
             productFactors("features"),
             dataset(factors(0)), dataset(factors(1)), dataset(factors(2))
  </code></pre>
  
  <p>If I do something like this, then the compiler says "Not applicable":</p>
  
  <pre><code>val myFactors = dataset.select(factors.head, factors.tail: _*)
  
  myFunction(userBias("bias"), 
             productBias("bias"),
             productBias("biases"),
             userFactors("features"), 
             productFactors("features"),
             myFactors)
  </code></pre>