Create DataFrame with null value for few column
<p>I am trying to create a <code>DataFrame</code> using <code>RDD</code>.</p>

<p>First I am creating a <code>RDD</code> using below code -</p>

<pre><code>val account = sc.parallelize(Seq(
                                 (1, null, 2,"F"), 
                                 (2, 2, 4, "F"),
                                 (3, 3, 6, "N"),
                                 (4,null,8,"F")))
</code></pre>

<p>It is working fine - </p>

<blockquote>
  <p>account: org.apache.spark.rdd.RDD[(Int, Any, Int, String)] =
  ParallelCollectionRDD[0] at parallelize at :27</p>
</blockquote>

<p>but when try to create <code>DataFrame</code> from the <code>RDD</code> using below code</p>

<pre><code>account.toDF("ACCT_ID", "M_CD", "C_CD","IND")
</code></pre>

<p>I am getting below error</p>

<blockquote>
  <p>java.lang.UnsupportedOperationException: Schema for type Any is not
  supported</p>
</blockquote>

<p>I analyzed that whenever I put <code>null</code> value in <code>Seq</code> then only I got the error.</p>

<p>Is there any way to add null value?</p>