[ 
https://issues.apache.org/jira/browse/BEAM-6241?focusedWorklogId=538533&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-538533
 ]

ASF GitHub Bot logged work on BEAM-6241:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Jan/21 16:24
            Start Date: 20/Jan/21 16:24
    Worklog Time Spent: 10m 
      Work Description: matthieucham commented on pull request #7293:
URL: https://github.com/apache/beam/pull/7293#issuecomment-763758511


   Hey guys, sorry to bother you, I don't know if it's the right place but I 
have some issues with what as been commited in this PR: It seems to me that 
multiple stages AggregationQuery pipelines are not correctly handled, because 
of this method:
   
   ```java
   public MongoCursor<Document> apply(@UnknownKeyFor @NonNull @Initialized 
MongoCollection<Document> collection) {
           if (this.bucket() != null) {
               if (this.mongoDbPipeline().size() == 1) {
                   this.mongoDbPipeline().add(this.bucket());
               } else {
                   this.mongoDbPipeline().set(this.mongoDbPipeline().size() - 
1, this.bucket());
               }
           }
   
           return collection.aggregate(this.mongoDbPipeline()).iterator();
       }
   ```
   
   The .set(...) looks very odd to me as it replaces the last stage of the 
pipeline, I don't get how that could be correct ? (Note that I'm new to MongoDB 
so maybe that explains...)
   
   Moreover, I wanted to test and override this by providing my own QueryFn, 
but it appears in MongoDBIO implementation that this function will be 
force-casted to either FilterQuery or AggregationQuery. Shouldn't we be able to 
provide any function as long as the contract is respected ?
   
   Hopefully, you're still reading this thread. Please point me to the right 
place if I should post this comment elsewhere
   
   Thanks


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 538533)
    Time Spent: 7h 40m  (was: 7.5h)

> Add support for aggregates using withQueryFn to MongoDbIO
> ---------------------------------------------------------
>
>                 Key: BEAM-6241
>                 URL: https://issues.apache.org/jira/browse/BEAM-6241
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-mongodb
>    Affects Versions: 2.9.0
>            Reporter: Ahmed El.Hussaini
>            Assignee: Ahmed El.Hussaini
>            Priority: P2
>              Labels: easyfix
>             Fix For: 2.12.0
>
>          Time Spent: 7h 40m
>  Remaining Estimate: 0h
>
> h2. Adds Support to Limit Results
>  
> {code:java}
> MongoDbIO.read()
> .withUri("mongodb://localhost:" + port)
> .withDatabase(DATABASE)
> .withCollection(COLLECTION)
> .withFilter("{\"scientist\":\"Einstein\"}")
> .withLimit(5));{code}
> h2. Adds Support to Use Aggregates
>  
> {code:java}
> List<BsonDocument> aggregates = new ArrayList<BsonDocument>();
>   aggregates.add(
>     new BsonDocument(
>       "$match",
>       new BsonDocument("country", new BsonDocument("$eq", new 
> BsonString("England")))));
> PCollection<Document> output =
>   pipeline.apply(
>     MongoDbIO.read()
>       .withUri("mongodb://localhost:" + port)
>       .withDatabase(DATABASE)
>       .withCollection(COLLECTION)
>       .withAggregate(aggregates));
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to