-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Code to re-create the issue:
public void writeDataToAtlasCluster(
final String pMongoUri,
final String pDataLakeCollection,
final String pDataLakeDatabase,
final String pAtlasCollectionName,
final String pAtlasDatabaseName,
final String pClusterName) {
final MongoClient mongoClient = new MongoClient(new MongoClientURI((pMongoUri)));
mongoClient
.getDatabase(pDataLakeDatabase)
.getCollection(pDataLakeCollection)
.aggregate(
List.of(
new Document()
.append(
"$out",
new Document(
"atlas",
new Document()
.append("clusterName", pClusterName)
.append("db", pAtlasDatabaseName)
.append("coll", pAtlasCollectionName))))).toCollection();
}
Resulting Error:
Exception in thread "main" org.bson.BsonInvalidOperationException: Value expected to be of type STRING is of unexpected type DOCUMENT at org.bson.BsonValue.throwIfInvalidType(BsonValue.java:419) at org.bson.BsonValue.asString(BsonValue.java:69) at org.bson.BsonDocument.getString(BsonDocument.java:234) at com.mongodb.client.internal.AggregateIterableImpl.getOutNamespace(AggregateIterableImpl.java:188) at com.mongodb.client.internal.AggregateIterableImpl.toCollection(AggregateIterableImpl.java:93) at TestAdlJava.writeDataToAtlasCluster(TestAdlJava.java:28) at TestAdlJava.main(TestAdlJava.java:40)