I’ve started working on writing some data to MongoDB via Spark. I have develop an application which writes to MongoDB via MongoDB Spark Connector.
Data sample is as below where null has to be written for null values. However, after writing the DataFrame to MongoDB with MongoSpark.save() the null column values doesn’t have entry.
Or in other words I could say, null values are not being written to Mongo and are exempted, however I would like retain those as below suffix tag. Can you please help me on this and let me know the way to achieve this.
"_id" : "999999", "firstName" : "ABC", "lastName" : "XYZ", "suffix" : null,
Note: With Json4s Jackson parser there is an option to choose noNulls if nulls are to be exempted. Default it will write null. However, I would like to use MongoDB Spark Connector because of its performance while writing to MongoDB through Spark.