title: Passing Array to Spark Lit function
body: <p>Let's say I have a numpy array <code>a</code> that contains the numbers 1-10:<br />
  <code>[1 2 3 4 5 6 7 8 9 10]</code></p>
  <p>I also have a Spark dataframe to which I want to add my numpy array <code>a</code>. I figure that a column of literals will do the job. This doesn't work:</p>
  <pre><code>df = df.withColumn(&quot;NewColumn&quot;, F.lit(a))
  </code></pre>
  <blockquote>
  <p>Unsupported literal type class java.util.ArrayList</p>
  </blockquote>
  <p>But this works:</p>
  <pre><code>df = df.withColumn(&quot;NewColumn&quot;, F.lit(a[0]))
  </code></pre>
  <p>How to do it?</p>
  <p>Example DF before:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>col1</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>a b c d e f g h i j</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Expected result:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>col1</th>
  <th>NewColumn</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>a b c d e f g h i j</td>
  <td>1 2 3 4 5 6 7 8 9 10</td>
  </tr>
  </tbody>
  </table>
  </div>