Description
When reading JSON/CSV files with inferring timestamp types `.option("inferTimestamp", true)`, the Timestamp conversion will throw and catch exceptions. As we are putting decent error messages in the exception, the creation of the exceptions is actually not cheap. It consumes more than 90% of the type inference time.
We can use the parsing methods which return optional results instead.
Before the change, it takes 166 seconds to infer a JSON file of 624MB with inferring timestamp enabled.
After the change, it only 16 seconds.