11-12-2021 06:50 AM
Hello everyone,
I'm trying to write to DocumentDB using org.mongodb.spark:mongo-spark-connector_2.12:3.0.1. The DocDB is version 4 which doesn't support Retryable Writes so I disabled the feature setting option "retryWrites" to "false" (also tried with False). However it didn't work. Do you know why?
uri = "mongodb://username:password@host.docdb.amazonaws.com:27017"
(df.write.format("mongo")
.option("uri", uri)
.option("retryWrites", "false")
.option("database", "mydb")
.option("collection", "employee")
.mode("append")
.save())
---
Command failed with error 301: Retryable writes are not supported
I tried to set the option directly on the uri like below, then it works, but I'd like to use .option() to set all the connection options. Is it possible?
uri = "mongodb://username:password@host.docdb.amazonaws.com:27017/?retryWrites=false"
Thanks!
11-12-2021 08:16 AM
Hi @Hugh Vo ,
I can't find retryWrites available as an option in the MongoDB connector: https://docs.mongodb.com/spark-connector/current/configuration/#input-configuration.
Looks like, it has to be passed as part of the URI.
11-12-2021 08:16 AM
Hi @Hugh Vo ,
I can't find retryWrites available as an option in the MongoDB connector: https://docs.mongodb.com/spark-connector/current/configuration/#input-configuration.
Looks like, it has to be passed as part of the URI.
11-12-2021 09:00 AM
Thanks @Sajesh Manakkunnath
11-12-2021 02:26 PM
@Hugh Vo - If Sajehs's answer resolved the issue, would you be happy to mark their answer as best?
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group