spark SQL - spark.read.option reading dd-MMM-yyyy from csv into dataFrame

Viewed 154

I have a CSV file with a column of string dd-MMM-yyyy (e.g. 03-APR-2019), which I want to read as date format.

my code to read as below:

 spark.read
      .option("header", "true")
      .option("inferSchema", "true")
      .option("quote", "\"")
      .option("escape", "\"")
      .option("multiLine", "true")
      .option("dateFormat", "dd-MMM-yyyy")
      .csv(csvInPath)

However, after my code read the CSV file, the date still appears as String in my data frame.

anyone can advise? thanks

0 Answers
Related