I have a pyspark dataframe which connects & read data from oracle database table. This dataframe has null values in some of the columns. I need to save this dataframe to a collection in mongodB.
pyspark dataframe looks something like this
| col1 | col2 | col3 |
|---|---|---|
| 10 | 5 | null |
| null | 6 | 'abc' |
If I write this dataframe to mongodB it is saving only col1 and col2 from 1st record to a document and col2 and col3 to another document.
But I need all the 3 columns available in the mongo document for each dataframe row. I need to convert this null values to None.
Then when If I write to mongodB I can see null value column names with value as null and type as null in mongo document.
I am using MongoDB Spark Connector for writing dataframe to mongo.
Please suggest how to convert null values to None.