title: Spark SQL query error
body: <p>I have a dataframe "dailyshow"
  Schema is:</p>
  
  <pre><code>scala&gt; dailyshow.printSchema
  root
   |-- year: integer (nullable = true)
   |-- occupation: string (nullable = true)
   |-- showdate: string (nullable = true)
   |-- group: string (nullable = true)
   |-- guest: string (nullable = true)
  </code></pre>
  
  <p>Sample Data is:</p>
  
  <pre><code>scala&gt; dailyshow.show(5)
  +----+------------------+---------+------+----------------+
  |year|        occupation| showdate| group|           guest|
  +----+------------------+---------+------+----------------+
  |1999|             actor|1/11/1999|Acting|  Michael J. Fox|
  |1999|          Comedian|1/12/1999|Comedy| Sandra Bernhard|
  |1999|television actress|1/13/1999|Acting|   Tracey Ullman|
  |1999|      film actress|1/14/1999|Acting|Gillian Anderson|
  |1999|             actor|1/18/1999|Acting|David Alan Grier|
  +----+------------------+---------+------+----------------+
  </code></pre>
  
  <p>Below code is used to transform and generate results which return the top 5 occupations between the time period "01/11/1999" and "06/11/1999"</p>
  
  <pre><code> sqlContext.sql("select occupation, count(*) as count from dailyshow 
   where to_date(cast(unix_timestamp(showdate,'MM/dd/yyyy') as 'timestamp')) &gt;= '1999-01-11' 
   and   to_date(cast(unix_timestamp(showdate,'MM/dd/yyyy') as 'timestamp'))  &lt;= '1999-06-11' 
   group by occupation 
   order by count 
   desc limit 5
   ")
  </code></pre>
  
  <p><strong>Below is the error:</strong></p>
  
  <pre><code>NoViableAltException(307@[])
      at org.apache.hadoop.hive.ql.parse.HiveParser.primitiveType(HiveParser.java:39374)
      at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.castExpression(HiveParser_IdentifiersParser.java:5434)
      at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.atomExpression(HiveParser_IdentifiersParser.java:6716)
  
  
  org.apache.spark.sql.AnalysisException: cannot recognize input near ''timestamp'' ')' ')' in primitive type specification; line 1 pos 112
      at org.apache.spark.sql.hive.HiveQl$.createPlan(HiveQl.scala:318)
      at org.apache.spark.sql.hive.ExtendedHiveQlParser$$anonfun$hiveQl$1.apply(ExtendedHiveQlParser.scala:41)
  </code></pre>
  
  <p>Kindly help..</p>