[COMPASS-4364] Compass pipeline export to Java not producing same results Created: 13/Jul/20  Updated: 27/Oct/23  Resolved: 30/Sep/20

Status: Closed
Project: Compass
Component/s: Export to Language
Affects Version/s: None
Fix Version/s: No version

Type: Bug Priority: Major - P3
Reporter: Sam Sam Assignee: Anna Herlihy (Inactive)
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Spring boot 2.3.1, MongoDB 4.2.8 Community ,Win 10


Attachments: File view.json     File wfsample.json    
Documentation Changes: Not Needed
Sprint: Iteration Jackfruit, Iteration Lime, Iteration Maracuja, Iteration Nectarine

 Description   

Mongo Pipeline

[\{$match: {[
 {$match: {  pd: 'PD',  type: 'type1',  date: {    $gte: '2019-01-01',    $lte: '2019-12-01'  }}}, 
 {$sort: {  pd: 1,  date: 1}}, 
 {$group: {  
      _id: {    site: '$site'  },  
       wf: {    $push: {      date: '$date',      resources: '$resources'}} {{        }  }, 
       resources: \{    $sum: '$resources'  }}}, \{$match: {  resources: {    $gt: 0  }}
  }
]

Arrays.asList(
    match(and(eq("pd", "PD"), eq("type", "type1"), and(gte("date", "2019-01-01"), lte("date", "2019-12-01")))), 
    sort(orderBy(ascending("pd"), ascending("date"))), 
    group(
          eq("site", "$site"),
          push("wf", and(eq("date", "$date"), eq("resources", "$resources"))), 
          sum("resources", "$resources")), match(gt("resources", 0L)));

Output from Mongo Query is in the attached file view.json

Output from Java aggregates framework is 

Document\{{_id=Document{{site=T}}, wf=[true, true, true, true, true, true, true, true, true, true, true, true], tresources=21.0}}}}
{{2020-07-08 14:19:53.095 INFO 24544 --- [ main] com.example.services.PcfReportsService : Document\{{_id=Document{{site=G}}, wf=[true, true, true, true, true, true, true, true, true, true, true, true], tresources=458.0}}}}

 
The problem is that the collected items in the group are returned as True and False which is not correct and also not what is produced when using this pipeline in shell . I have no other option but to post it here as a bug . Currently I am using @aggregates to do this operation. Also It would be nice to pass the pipeline array as a single string in aggregation parameter. Currently I break the pipeline above  and add it as @aggregation(pipeline={p1,p2,p3...pn}).



 Comments   
Comment by Jessica Sigafoos [ 30/Sep/20 ]

Hi abledear@gmail.com! There hasn't been any recent activity on this HELP ticket, so we're resolving it. Thanks for reaching out! Please feel free to reopen with the information requested in the last comment if you'd like!

Comment by Anna Herlihy (Inactive) [ 14/Sep/20 ]

Hi, abledear@gmail.com, could you please answer a few questions to help me understand the problem?

1. You are putting an aggregation in the Compass agg pipeline builder and then exporting it to Java, then running the aggregation using the Java driver, correct? You said the output is different from what you got from the shell - does Compass return the same thing as the shell? Is it just the output from the Java driver that is different?

2. Could you please provide us with the exact aggregation that was input to Compass in JavaScript? It looks like there may have been some formatting that got copied into the ticket that makes it difficult to follow what the exact input into the agg pipeline builder was. If you could attach both the left and the righthand side of the export to language popup window, that would be very useful.

3. If you untick the 'use builders' box and run the Java code that is generated, does the problem still persist? If you could attach that output as well it would be helpful.

 

Thank you!

Generated at Wed Feb 07 22:36:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.