title: To_Date function always returns null
body: <p>I have a string formatted column which I get via:</p>
  
  <pre><code>session.sql("select milestoneactualdate from dba")
  </code></pre>
  
  <p>This column contans data like "20190101". I want to cast this string to date via:</p>
  
  <pre><code>session.sql("select *, to_date(milestoneactualdate, '%YYYY%MM%DD') as datetest from dba").show()
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>changedTypedf = df.withColumn("milestoneactualdate", to_date(df["milestoneactualdate"], '%YYYY%MM%DD').cast('Date'))
  </code></pre>
  
  <p>But it always returns "null". Why is my cast function not working?</p>