title: Spark: error reading DateType columns in partitioned parquet data
body: <p>I have parquet data in S3 partitioned by nyc_date in the format <code>s3://mybucket/mykey/nyc_date=Y-m-d/*.gz.parquet</code>.</p>
  
  <p>I have a DateType column <code>event_date</code> that for some reason throws this error when I try to read from S3 and write to hdfs using EMR.</p>
  
  <pre><code>from pyspark.sql import SparkSession
  
  spark = SparkSession.builder.enableHiveSupport().getOrCreate()
  df = spark.read.parquet('s3a://mybucket/mykey/') 
  
  df.limit(100).write.parquet('hdfs:///output/', compression='gzip')
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>java.lang.UnsupportedOperationException: org.apache.parquet.column.values.dictionary.PlainValuesDictionary$PlainBinaryDictionary
      at org.apache.parquet.column.Dictionary.decodeToInt(Dictionary.java:48)
      at org.apache.spark.sql.execution.vectorized.OnHeapColumnVector.getInt(OnHeapColumnVector.java:233)
      at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIterator.processNext(Unknown Source)
      at org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)
      at org.apache.spark.sql.execution.WholeStageCodegenExec$$anonfun$8$$anon$1.hasNext(WholeStageCodegenExec.scala:370)
      at scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:389)
      at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
      at org.apache.spark.shuffle.sort.BypassMergeSortShuffleWriter.write(BypassMergeSortShuffleWriter.java:125)
      at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:79)
      at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:47)
      at org.apache.spark.scheduler.Task.run(Task.scala:86)
      at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:274)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>Here's what I figured out:</p>
  
  <ul>
  <li><strong>Local works :-)</strong>: I copied over some data locally in the same format and can query fine.</li>
  <li><strong>Avoid selecting event_date works :-)</strong>: Selecting all 50+ columns but for <code>event_date</code> doesn't cause any errors.</li>
  <li><strong>Explicit read path throws error :-(</strong>: Changing the read path to <code>'s3a://mybucket/mykey/*/*.gz.parquet'</code> still throws error.</li>
  <li><strong>Specifying schema still throws error :-(</strong>: specifying the schema before loading still causes the same error.</li>
  <li>I can load the data including eastern_date into a data warehouse :-).</li>
  </ul>
  
  <p>Really weird this causes an error only for a DateType column. I don't have any other DateType columns.</p>
  
  <p>Using Spark 2.0.2 and EMR 5.2.0.</p>