Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3777

Driver 3.11.x - $out fails with Value expected to be of type STRING is of unexpected type DOCUMENT

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      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)
      

      Attachments

        Activity

          People

            jeff.yemin@mongodb.com Jeffrey Yemin
            ralph.capasso@mongodb.com Ralph Capasso
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: