Hi,
MongoDB Spark Connector has a bug in the method: isJsonObjectOrArray
File: RowToBsonDocumentConverter.java
Method: isJsonObjectOrArray (Line: 221)
Ref: https://github.com/mongodb/mongo-spark/blob/main/src/main/java/com/mongodb/spark/sql/connector/schema/RowToBsonDocumentConverter.java?#L221
Issue: Code always assumes string is not empty and access index 0/1. So when data has empty string ‘’ , get error: Can not convert to Bson, Index out of range
Suggested Fix: Its just bool method checking if value should be converted to BSON or not. Just returning false on empty strings will do?
OR provide easier way to just convert ONLY specified column to convert to BSON. We only need to use this for one column - Id to ObjectId - But as its not supported, we have to use it as top-level option that applies to all Object/Arrays.
Suggested Fix is very simple. Is there a way to get hot fix release, if we have support plan?