I am reading a DF with the following schema:
StructType(List(StructField(transaction_id,StringType,false),StructField(date,TimestampType,true),StructField(time,TimestampType,true),StructField(customer_id,StringType,true),StructField(to_customer_id,StringType,true),StructField(mobile_number,StringType,true),StructField(to_mobile_number,StringType,true),StructField(card_number,StringType,true),StructField(service,StringType,true),StructField(reference_1,StringType,true),StructField(reference_2,StringType,true),StructField(pos_id,StringType,true),StructField(status,StringType,true),StructField(void,StringType,true),StructField(void_date,StringType,true),StructField(refund_no,StringType,true),StructField(remarks,StringType,true),StructField(amount,FloatType,true),StructField(description,StringType,true),StructField(currency_code,StringType,true),StructField(merchant_name,StringType,true),StructField(merchant_id,LongType,true),StructField(trx_district,StringType,true),StructField(city,StringType,true),StructField(lat,StringType,true),StructField(long,StringType,true),StructField(formatted_address,StringType,true),StructField(district,StringType,true)))
And I am writing it back to a MongoDB. But getting the following error:
com.mongodb.spark.exceptions.MongoTypeConversionException: Cannot cast -2.0 into a BsonValue. FloatType has no matching BsonValue.
It is referring to the StructField(amount,FloatType,true)
Kindly help,
Thanks,