Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove distinct from non-count aggregations #6023

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class AggregationAttributeField extends AggregationField {
.return(projection);
}

return new Cypher.With(target).distinct().return([this.getAggregationExpr(target), returnVar]);
return new Cypher.With(target).return([this.getAggregationExpr(target), returnVar]);
}

private createAggregationExpr(target: Cypher.Variable | Cypher.Property): Cypher.Expr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ describe("Field Level Aggregations", () => {
age: {
max: 54,
min: 37,
average: 45.5,
sum: 91,
average: expect.closeTo(48.33),
sum: 145,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("Cypher Aggregations Many with Alias directive", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { shortest: min(this._id), longest: max(this._id) } AS var0
}
CALL {
Expand All @@ -81,12 +81,12 @@ describe("Cypher Aggregations Many with Alias directive", () => {
}
CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: min(this.\`_imdb Rating\`), max: max(this.\`_imdb Rating\`), average: avg(this.\`_imdb Rating\`) } AS var2
}
CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: apoc.date.convertFormat(toString(min(this._createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\"), max: apoc.date.convertFormat(toString(max(this._createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\") } AS var3
}
RETURN { id: var0, title: var1, imdbRating: var2, createdAt: var3 }"
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/tests/tck/aggregations/alias.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("Cypher Aggregations Many while Alias fields", () => {
}
CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { _shortest: min(this.id), _longest: max(this.id) } AS var1
}
CALL {
Expand All @@ -86,12 +86,12 @@ describe("Cypher Aggregations Many while Alias fields", () => {
}
CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { _min: min(this.imdbRating), _max: max(this.imdbRating), _average: avg(this.imdbRating) } AS var3
}
CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { _min: apoc.date.convertFormat(toString(min(this.createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\"), _max: apoc.date.convertFormat(toString(max(this.createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\") } AS var4
}
RETURN { _count: var0, _id: var1, _title: var2, _imdbRating: var3, _createdAt: var4 }"
Expand Down
10 changes: 5 additions & 5 deletions packages/graphql/tests/tck/aggregations/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe("Cypher Aggregations with Auth", () => {
"CALL {
MATCH (this:User)
WHERE (($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)) AND apoc.util.validatePredicate(NOT ($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)), \\"@neo4j/graphql/FORBIDDEN\\", [0]))
WITH DISTINCT this
WITH this
RETURN { min: min(this.imdbRatingInt), max: max(this.imdbRatingInt) } AS var0
}
RETURN { imdbRatingInt: var0 }"
Expand Down Expand Up @@ -188,7 +188,7 @@ describe("Cypher Aggregations with Auth", () => {
"CALL {
MATCH (this:User)
WHERE (($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)) AND apoc.util.validatePredicate(NOT ($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)), \\"@neo4j/graphql/FORBIDDEN\\", [0]))
WITH DISTINCT this
WITH this
RETURN { min: min(this.imdbRatingFloat), max: max(this.imdbRatingFloat) } AS var0
}
RETURN { imdbRatingFloat: var0 }"
Expand Down Expand Up @@ -224,7 +224,7 @@ describe("Cypher Aggregations with Auth", () => {
"CALL {
MATCH (this:User)
WHERE (($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)) AND apoc.util.validatePredicate(NOT ($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)), \\"@neo4j/graphql/FORBIDDEN\\", [0]))
WITH DISTINCT this
WITH this
RETURN { min: min(this.imdbRatingBigInt), max: max(this.imdbRatingBigInt) } AS var0
}
RETURN { imdbRatingBigInt: var0 }"
Expand Down Expand Up @@ -260,7 +260,7 @@ describe("Cypher Aggregations with Auth", () => {
"CALL {
MATCH (this:User)
WHERE (($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)) AND apoc.util.validatePredicate(NOT ($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)), \\"@neo4j/graphql/FORBIDDEN\\", [0]))
WITH DISTINCT this
WITH this
RETURN { shortest: min(this.id), longest: max(this.id) } AS var0
}
RETURN { id: var0 }"
Expand Down Expand Up @@ -334,7 +334,7 @@ describe("Cypher Aggregations with Auth", () => {
"CALL {
MATCH (this:User)
WHERE (($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)) AND apoc.util.validatePredicate(NOT ($isAuthenticated = true AND ($jwt.sub IS NOT NULL AND this.id = $jwt.sub)), \\"@neo4j/graphql/FORBIDDEN\\", [0]))
WITH DISTINCT this
WITH this
RETURN { min: apoc.date.convertFormat(toString(min(this.createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\"), max: apoc.date.convertFormat(toString(max(this.createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\") } AS var0
}
RETURN { createdAt: var0 }"
Expand Down
10 changes: 5 additions & 5 deletions packages/graphql/tests/tck/aggregations/bigint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Cypher Aggregations BigInt", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:File)
WITH DISTINCT this
WITH this
RETURN { min: min(this.size) } AS var0
}
RETURN { size: var0 }"
Expand All @@ -77,7 +77,7 @@ describe("Cypher Aggregations BigInt", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:File)
WITH DISTINCT this
WITH this
RETURN { max: max(this.size) } AS var0
}
RETURN { size: var0 }"
Expand All @@ -102,7 +102,7 @@ describe("Cypher Aggregations BigInt", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:File)
WITH DISTINCT this
WITH this
RETURN { average: avg(this.size) } AS var0
}
RETURN { size: var0 }"
Expand All @@ -127,7 +127,7 @@ describe("Cypher Aggregations BigInt", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:File)
WITH DISTINCT this
WITH this
RETURN { sum: sum(this.size) } AS var0
}
RETURN { size: var0 }"
Expand Down Expand Up @@ -155,7 +155,7 @@ describe("Cypher Aggregations BigInt", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:File)
WITH DISTINCT this
WITH this
RETURN { min: min(this.size), max: max(this.size), average: avg(this.size), sum: sum(this.size) } AS var0
}
RETURN { size: var0 }"
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/tests/tck/aggregations/datetime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Cypher Aggregations DateTime", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: apoc.date.convertFormat(toString(min(this.createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\") } AS var0
}
RETURN { createdAt: var0 }"
Expand All @@ -77,7 +77,7 @@ describe("Cypher Aggregations DateTime", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { max: apoc.date.convertFormat(toString(max(this.createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\") } AS var0
}
RETURN { createdAt: var0 }"
Expand All @@ -103,7 +103,7 @@ describe("Cypher Aggregations DateTime", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: apoc.date.convertFormat(toString(min(this.createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\"), max: apoc.date.convertFormat(toString(max(this.createdAt)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\") } AS var0
}
RETURN { createdAt: var0 }"
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/tests/tck/aggregations/duration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Cypher Aggregations Duration", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: min(this.screenTime) } AS var0
}
RETURN { screenTime: var0 }"
Expand All @@ -77,7 +77,7 @@ describe("Cypher Aggregations Duration", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { max: max(this.screenTime) } AS var0
}
RETURN { screenTime: var0 }"
Expand All @@ -103,7 +103,7 @@ describe("Cypher Aggregations Duration", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: min(this.screenTime), max: max(this.screenTime) } AS var0
}
RETURN { screenTime: var0 }"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe("Field Level Aggregations Alias", () => {
CALL {
WITH this
MATCH (this)<-[this0:ACTED_IN]-(this1:Actor)
WITH DISTINCT this0
WITH this0
RETURN { max: max(this0.screentime) } AS var2
}
RETURN this { actorsAggregate: { edge: { time: var2 } } } AS this"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("Field Level Aggregations", () => {
CALL {
WITH this
MATCH (this)<-[this0:ACTED_IN]-(this1:Actor)
WITH DISTINCT this0
WITH this0
RETURN { min: min(this0.screentime), max: max(this0.screentime), average: avg(this0.screentime), sum: sum(this0.screentime) } AS var2
}
RETURN this { actorsAggregate: { edge: { screentime: var2 } } } AS this"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe("Field Level Aggregations", () => {
CALL {
WITH this
MATCH (this)<-[this0:ACTED_IN]-(this1:Actor)
WITH DISTINCT this1
WITH this1
RETURN { min: min(this1.age), max: max(this1.age), average: avg(this1.age), sum: sum(this1.age) } AS var2
}
RETURN this { actorsAggregate: { node: { age: var2 } } } AS this"
Expand Down Expand Up @@ -224,7 +224,7 @@ describe("Field Level Aggregations", () => {
CALL {
WITH this
MATCH (this)-[this0:ACTED_IN]->(this1:Movie)
WITH DISTINCT this1
WITH this1
RETURN { min: apoc.date.convertFormat(toString(min(this1.released)), \\"iso_zoned_date_time\\", \\"iso_offset_date_time\\") } AS var2
}
RETURN this { moviesAggregate: { node: { released: var2 } } } AS this"
Expand Down Expand Up @@ -270,7 +270,7 @@ describe("Field Level Aggregations", () => {
CALL {
WITH this
MATCH (this)<-[this3:ACTED_IN]-(this4:Actor)
WITH DISTINCT this4
WITH this4
RETURN { min: min(this4.age), max: max(this4.age), average: avg(this4.age), sum: sum(this4.age) } AS var5
}
RETURN this { actorsAggregate: { node: { name: var2, age: var5 } } } AS this"
Expand Down
12 changes: 6 additions & 6 deletions packages/graphql/tests/tck/aggregations/float.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Cypher Aggregations Float", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: min(this.actorCount) } AS var0
}
RETURN { actorCount: var0 }"
Expand All @@ -77,7 +77,7 @@ describe("Cypher Aggregations Float", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { max: max(this.actorCount) } AS var0
}
RETURN { actorCount: var0 }"
Expand All @@ -102,7 +102,7 @@ describe("Cypher Aggregations Float", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { average: avg(this.actorCount) } AS var0
}
RETURN { actorCount: var0 }"
Expand All @@ -127,7 +127,7 @@ describe("Cypher Aggregations Float", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { sum: sum(this.actorCount) } AS var0
}
RETURN { actorCount: var0 }"
Expand Down Expand Up @@ -155,7 +155,7 @@ describe("Cypher Aggregations Float", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: min(this.actorCount), max: max(this.actorCount), average: avg(this.actorCount), sum: sum(this.actorCount) } AS var0
}
RETURN { actorCount: var0 }"
Expand Down Expand Up @@ -188,7 +188,7 @@ describe("Cypher Aggregations Float", () => {
}
CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: min(this.actorCount), max: max(this.actorCount), average: avg(this.actorCount), sum: sum(this.actorCount) } AS var1
}
RETURN { count: var0, actorCount: var1 }"
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/tests/tck/aggregations/id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Cypher Aggregations ID", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { shortest: min(this.id) } AS var0
}
RETURN { id: var0 }"
Expand All @@ -77,7 +77,7 @@ describe("Cypher Aggregations ID", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { longest: max(this.id) } AS var0
}
RETURN { id: var0 }"
Expand All @@ -103,7 +103,7 @@ describe("Cypher Aggregations ID", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { shortest: min(this.id), longest: max(this.id) } AS var0
}
RETURN { id: var0 }"
Expand Down
10 changes: 5 additions & 5 deletions packages/graphql/tests/tck/aggregations/int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Cypher Aggregations Int", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: min(this.imdbRating) } AS var0
}
RETURN { imdbRating: var0 }"
Expand All @@ -77,7 +77,7 @@ describe("Cypher Aggregations Int", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { max: max(this.imdbRating) } AS var0
}
RETURN { imdbRating: var0 }"
Expand All @@ -102,7 +102,7 @@ describe("Cypher Aggregations Int", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { average: avg(this.imdbRating) } AS var0
}
RETURN { imdbRating: var0 }"
Expand All @@ -127,7 +127,7 @@ describe("Cypher Aggregations Int", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { sum: sum(this.imdbRating) } AS var0
}
RETURN { imdbRating: var0 }"
Expand Down Expand Up @@ -155,7 +155,7 @@ describe("Cypher Aggregations Int", () => {
expect(formatCypher(result.cypher)).toMatchInlineSnapshot(`
"CALL {
MATCH (this:Movie)
WITH DISTINCT this
WITH this
RETURN { min: min(this.imdbRating), max: max(this.imdbRating), average: avg(this.imdbRating), sum: sum(this.imdbRating) } AS var0
}
RETURN { imdbRating: var0 }"
Expand Down
Loading