mongo-spark
mongo-spark copied to clipboard
[SPARK-346] Fix convert date type to bson
When I try to write a databricks data frame with DateType to mongodb, I got Error: Cannot cast 2022-05-13 into a BsonValue. DateType has no matching BsonValue. Error: java.sql.Date cannot be cast to java.sql.Timestamp
I found that the connector treats DateType as jave.sql.Timestamp during conversion, however, DateType should be jave.sql.Date and jave.sql.Date can't be casted as jave.sql.Timestamp
This PR fixes the DateType to bson conversion, and also adds a test case to ensure the conversion works as expected.