-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 1.22.1
-
Component/s: Aggregation pipeline
-
None
-
Environment:node.js / npm versions: v12.12.0 / 6.13.4
OS: OS X 10.15.7
Java Driver : 4.0.5
-
Iteration Uglifruit
-
Not Needed
I've built a pipeline in Compass that uses a project phase with $reduce:
I have a project phase that also uses $reduce:
{ _id: 0, title: '$playlist.songs.title', artist: { $reduce: { input: '$playlist.songs.artists.name', initialValue: "", in: { $concat : ["$$value", " ", "$$this"] } } } }
The pipeline executes fine in Compass and gives me back to documents I expect.
However, when I export to Java driver code, the code that is generated results in a runtime error in my application.
Here is the Java code that is generated is:
project( fields( excludeId(), computed("title", "$playlist.songs.title"), computed("artist", eq("$reduce", and( eq("input", "$playlist.songs.artists.name"), eq("initialValue", ""), eq("in", eq("$concat", Arrays.asList("$$value", " ", "$$this"))))))))
And the error that is returned:
com.mongodb.MongoCommandException: Command failed with error 40076 (Location40076): '$reduce found an unknown argument: $and'
As some background, this was a pipeline I generated over a year ago (not sure the precise Compass version) and it worked fine with Java driver 3.x and Server 3.x. A few months ago the server was upgraded to 4.x, and the pipeline continued to run fine using Java driver 3.x.
It wasn't until I upgraded the Java driver to 4.x that this issue came up.
I have rebuilt the pipeline in the latest Compass version, and confirmed it still generates the same snippet of Java code that results in the error.
- depends on
-
JAVA-3956 Add a helper method to the fluid API to create a document from other fluid method
- Backlog
- is duplicated by
-
COMPASS-4512 Error generating java code
- Closed
- is related to
-
COMPASS-4341 export to Java doesn't like $size expression inside other expressions
- Needs Triage
-
COMPASS-4111 Export $lookup aggregate to java fails
- Closed
- related to
-
JAVA-3338 $geoWithin cannot contain multiple fields
- Closed
-
COMPASS-4695 Bring back builders in export to language for Java
- Closed