title: Specifying Schema of CSV in Apache Spark
body: <p>I am getting an error in what should be a simple case:</p>
  
  <p>I want to read a bunch of CSVs, all have the same format, but no headers.</p>
  
  <p>So, I am trying to specify the headers.</p>
  
  <pre><code>from pyspark.sql import SQLContext
  from pyspark.sql.types import *
  sqlContext = SQLContext(sc)
  
  schema = StructType([        
      StructField("c0", StringType(), True),    
      StructField("c1", StringType(), True),
      StructField("c2", StringType(), True),
      StructField("c3", TimestampType, True),
      StructField("c4", TimestampType, True),
      StructField("c5", StringType(), True),
      StructField("c6", StringType(), True),
      StructField("c7", StringType(), True),
      StructField("c8", StringType(), True),
      StructField("c9", StringType(), True),
      StructField("c10", StringType(), True),
      StructField("c11", StringType(), True),
      StructField("c12", StringType(), True),
      StructField("c13", StringType(), True),
      StructField("c14", StringType(), True),
      StructField("c15", StringType(), True),
      StructField("c16", StringType(), True),
      StructField("c17", StringType(), True)    
      ])
  
  df = sqlContext.read.load('good_loc.csv', 
                            format='com.databricks.spark.csv', 
                            header='false', 
                            inferSchema='true')
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>dataType should be DataType
  Traceback (most recent call last):
    File "/usr/hdp/current/spark2-client/python/pyspark/sql/types.py", line 403, in __init__
      assert isinstance(dataType, DataType), "dataType should be DataType"
  AssertionError: dataType should be DataType
  </code></pre>
  
  <p>The error I think is coming from TimeStamp Type. I am using Spark 2.2</p>
  
  <p>Thanks for the help!</p>