spring-projects / spring-projects/spring-data-mongodb

Incorrect name of derived fields in group aperation after project operation. [DATAMONGO-1359]

Open
#2,256 0 comments 0 reactions 1 assignee View on GitHub

@christophstrobl is already working on this.

Since Dec 30, 2020.

in: aggregation-framework type: bug
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Francisco José Cadaval Arrola opened DATAMONGO-1359 and commented

When I project field "measures.max" as "max" in a projection operation and after it I try to get maximun of it in a group operation, the group operation establish the max over "$measures.max" instead of "$max".

Width this code:

List<AggregationOperation> list = new ArrayList<AggregationOperation>();
		
ProjectionOperation projection = Aggregation.project("reference").and("measures.max").as("max");
GroupOperation group = Aggregation.group("reference").max("max").as("max");
		
list.add(projection);
list.add(group);
		
Aggregation aggregation = Aggregation.newAggregation(list);

The aggregation is:

{ "aggregate" : "__collection__" , "pipeline" : [
    { "$project" : { "reference" : 1 , "max" : "$measures.max"}} ,
    { "$group" : { "_id" : "$reference" , "max" : { "$max" : "$measures.max"}}}
]}

while it should be:

{ "aggregate" : "__collection__" , "pipeline" : [
    { "$project" : { "reference" : 1 , "max" : "$measures.max"}} ,
    { "$group" : { "_id" : "$reference" , "max" : { "$max" : "$max"}}}
]}

It is similar to DATAMONGO-1254


Affects: 1.8.4 (Gosling SR4)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.