mongo-spark icon indicating copy to clipboard operation
mongo-spark copied to clipboard

[SPARK-346] Fix convert date type to bson

Open tsekityam opened this issue 2 years ago • 0 comments

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.

tsekityam avatar May 13 '22 18:05 tsekityam