You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/05/16 08:08:35 UTC

[GitHub] [spark] SaurabhChawla100 commented on a change in pull request #32558: [SPARK-34953][CORE][SQL] Add the code change for adding the DateType in the infer schema while reading

SaurabhChawla100 commented on a change in pull request #32558:
URL: https://github.com/apache/spark/pull/32558#discussion_r633059406



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/csv/CSVInferSchema.scala
##########
@@ -168,6 +169,15 @@ class CSVInferSchema(val options: CSVOptions) extends Serializable {
     // This case infers a custom `dataFormat` is set.
     if ((allCatch opt timestampParser.parse(field)).isDefined) {
       TimestampType
+    } else {
+      tryParseDateFormat(field)
+    }
+  }
+
+  private def tryParseDateFormat(field: String): DataType = {
+    if ((allCatch opt new SimpleDateFormat(

Review comment:
       @HyukjinKwon  - Sorry , I forget to push the latest commit  where I was setting setLenient(false) , This will help with the exact match.
   
   ```
     val dtFormat = new SimpleDateFormat(options.dateFormat, Locale.US)
         dtFormat.setLenient(false)
         dtFormat.parse(field)}).isDefined) {
         DateType
       }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org