'MongoSpark cast ISODate object
I am trying to read a collection from mongo using MongoSpark with a timestamp field called TimeInstant:

I have a problem with this timestamp type field. It seems that some of the values of this field in the collection are with a empty String, so mongo infers this field for me as a string. The problem is that instead of returning a String with the timestamp, it returns an object that looks like this:
The problem is that when I try to cast this field to TimestampType it returns null values. My question is how can I cast this $date object to timestamp. I have tried to increase the number of samples when reading from mongo but it keeps inferring this field as a string
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

