title: Null values in timestamp StructField
body: <p>How can I handle null values in Timestamp column ? </p>
  
  <p>I have source data saved in List (result of sql)</p>
  
  <pre><code>List([222,1,222,222,2012-01-28 23:37:06.0,()], 
       [220,1,220,220,2012-04-24 23:37:08.0,()], 
       [220,1,220,220,2008-03-18 15:06:09.0,()],
       ... 
  </code></pre>
  
  <p>In the last column are null values mixed with timestamps. </p>
  
  <p>But when I try to load this as RDD</p>
  
  <pre><code>//Create RDD
  val rdd = spark.sparkContext.makeRDD(res.toList)
  
  // Create schema fields
  val fields = List (StructField("value", StringType, nullable = true)
                    ,StructField("hit_count", IntegerType, nullable = true)
                    ,StructField("range_start", StringType, nullable = true)
                    ,StructField("range_end", StringType, nullable = true)
                    ,StructField("valid_from", TimestampType, nullable = true)
                    ,StructField("valid_to", TimestampType, nullable = true))
  
  // Create DataFrame
  val dataFrame = spark.createDataFrame(rdd, StructType(fields))
  </code></pre>
  
  <p>I'm getting exception </p>
  
  <blockquote>
    <p>Caused by: java.lang.RuntimeException: scala.runtime.BoxedUnit is not
    a valid external type for schema of timestamp</p>
  </blockquote>
  
  <p>So Null values are wrapped as BoxedUnit which have different type other than TimestampType. </p>
  
  <p>How can I handle this ? Is it possible to have mixed datatypes in one column, or do I have to map all null values into "null timestamp" ?</p>