@Alok Thampi - I understand your concern about the badRecordsPath option not logging the erroneous values for the DateType() column. It is possible that this is a bug or limitation in Spark's CSV reader implementation.
Regarding your question about rows 3 and 4, when Spark encounters a new line character in a CSV file, it treats it as a new record. In your case, row 2 is being treated as a separate record because of the new line character at the end of the line. Rows 3 and 4 are also being treated as separate records because they are on separate lines. However, since rows 3 and 4 do not conform to the schema, they are being skipped by Spark.
Regarding your test with the TimestampType() column, it is possible that this data type is more forgiving than the DateType() column when it comes to parsing invalid date formats. This could be why it is able to load the correct records and push the error row to the bad_records folder.
In summary, it seems that the issue is related to the DateType() column and how Spark's CSV reader handles invalid date formats. Changing the data type to a more forgiving type, such as TimestampType(), or removing the new line characters from the source file may help in this case.
I hope this helps! Let me know if you have any further questions.