Skip to content

Commit

Permalink
Fix deduplication bug related to @stream (#2304)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie authored Jan 7, 2025
2 parents 00d79e6 + dd3d22e commit 12c908f
Show file tree
Hide file tree
Showing 61 changed files with 10,618 additions and 9,951 deletions.
6 changes: 6 additions & 0 deletions .changeset/fuzzy-tools-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"grafast": patch
---

Fix bug where streamed and non-streamed steps could be deduplicated; and use a
cloned subplan for pageInfo calculations.
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,45 @@ graph TD
PgSelect10 ==> __Item14
PgSelectSingle15{{"PgSelectSingle[15∈1]<br />ᐸforumsᐳ"}}:::plan
__Item14 --> PgSelectSingle15
Constant58{{"Constant[58∈1] ➊<br />ᐸfalseᐳ"}}:::plan
Constant59{{"Constant[59∈1] ➊<br />ᐸfalseᐳ"}}:::plan
PgClassExpression16{{"PgClassExpression[16∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
PgSelectSingle15 --> PgClassExpression16
PgSelect29[["PgSelect[29∈3]<br />ᐸmessagesᐳ"]]:::plan
PgClassExpression22{{"PgClassExpression[22∈3]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
PgClassExpression28{{"PgClassExpression[28∈3]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
Object13 & PgClassExpression22 & PgClassExpression28 & Connection27 --> PgSelect29
PgSelect72[["PgSelect[72∈3]<br />ᐸmessages(aggregate)ᐳ"]]:::plan
Object13 & PgClassExpression22 & PgClassExpression28 & Connection27 --> PgSelect72
PgSelect73[["PgSelect[73∈3]<br />ᐸmessages(aggregate)ᐳ"]]:::plan
Object13 & PgClassExpression22 & PgClassExpression28 & Connection27 --> PgSelect73
PgSelectSingle15 --> PgClassExpression22
PgSelectSingle15 --> PgClassExpression28
PgPageInfo57{{"PgPageInfo[57∈3] ➊"}}:::plan
Connection27 --> PgPageInfo57
First61{{"First[61∈3]"}}:::plan
PgSelect29 --> First61
PgSelectSingle62{{"PgSelectSingle[62∈3]<br />ᐸmessagesᐳ"}}:::plan
First61 --> PgSelectSingle62
PgCursor63{{"PgCursor[63∈3]"}}:::plan
List65{{"List[65∈3]<br />ᐸ64ᐳ"}}:::plan
List65 --> PgCursor63
PgClassExpression64{{"PgClassExpression[64∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
PgSelectSingle62 --> PgClassExpression64
PgClassExpression64 --> List65
Last67{{"Last[67∈3]"}}:::plan
PgSelect29 --> Last67
PgSelectSingle68{{"PgSelectSingle[68∈3]<br />ᐸmessagesᐳ"}}:::plan
Last67 --> PgSelectSingle68
PgCursor69{{"PgCursor[69∈3]"}}:::plan
List71{{"List[71∈3]<br />ᐸ70ᐳ"}}:::plan
List71 --> PgCursor69
PgClassExpression70{{"PgClassExpression[70∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
PgSelectSingle68 --> PgClassExpression70
PgClassExpression70 --> List71
First73{{"First[73∈3]"}}:::plan
PgSelect72 --> First73
PgSelectSingle74{{"PgSelectSingle[74∈3]<br />ᐸmessagesᐳ"}}:::plan
First73 --> PgSelectSingle74
PgClassExpression75{{"PgClassExpression[75∈3]<br />ᐸcount(*)ᐳ"}}:::plan
PgSelectSingle74 --> PgClassExpression75
PgPageInfo58{{"PgPageInfo[58∈3] ➊"}}:::plan
Connection27 --> PgPageInfo58
First62{{"First[62∈3]"}}:::plan
PgSelect29 --> First62
PgSelectSingle63{{"PgSelectSingle[63∈3]<br />ᐸmessagesᐳ"}}:::plan
First62 --> PgSelectSingle63
PgCursor64{{"PgCursor[64∈3]"}}:::plan
List66{{"List[66∈3]<br />ᐸ65ᐳ"}}:::plan
List66 --> PgCursor64
PgClassExpression65{{"PgClassExpression[65∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
PgSelectSingle63 --> PgClassExpression65
PgClassExpression65 --> List66
Last68{{"Last[68∈3]"}}:::plan
PgSelect29 --> Last68
PgSelectSingle69{{"PgSelectSingle[69∈3]<br />ᐸmessagesᐳ"}}:::plan
Last68 --> PgSelectSingle69
PgCursor70{{"PgCursor[70∈3]"}}:::plan
List72{{"List[72∈3]<br />ᐸ71ᐳ"}}:::plan
List72 --> PgCursor70
PgClassExpression71{{"PgClassExpression[71∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
PgSelectSingle69 --> PgClassExpression71
PgClassExpression71 --> List72
First74{{"First[74∈3]"}}:::plan
PgSelect73 --> First74
PgSelectSingle75{{"PgSelectSingle[75∈3]<br />ᐸmessagesᐳ"}}:::plan
First74 --> PgSelectSingle75
PgClassExpression76{{"PgClassExpression[76∈3]<br />ᐸcount(*)ᐳ"}}:::plan
PgSelectSingle75 --> PgClassExpression76
__Item30[/"__Item[30∈4]<br />ᐸ29ᐳ"\]:::itemplan
PgSelect29 ==> __Item30
PgSelectSingle31{{"PgSelectSingle[31∈4]<br />ᐸmessagesᐳ"}}:::plan
Expand Down Expand Up @@ -110,13 +110,13 @@ graph TD
class Bucket0,__Value2,__Value4,PgSelect10,Access11,Access12,Object13,Connection27 bucket0
Bucket1("Bucket 1 (listItem)<br />Deps: 13, 27<br /><br />ROOT __Item{1}ᐸ10ᐳ[14]"):::bucket
classDef bucket1 stroke:#00bfff
class Bucket1,__Item14,PgSelectSingle15,Constant58 bucket1
Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 15, 13, 27, 58<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[15]"):::bucket
class Bucket1,__Item14,PgSelectSingle15,Constant59 bucket1
Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 15, 13, 27, 59<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[15]"):::bucket
classDef bucket2 stroke:#7f007f
class Bucket2,PgClassExpression16 bucket2
Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 15, 13, 27, 58<br /><br />ROOT Connectionᐸ23ᐳ[27]<br />1: <br />ᐳ: 22, 28, 57<br />2: PgSelect[29], PgSelect[72]<br />ᐳ: 61, 62, 64, 65, 67, 68, 70, 71, 73, 74, 75, 63, 69"):::bucket
Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 15, 13, 27, 59<br /><br />ROOT Connectionᐸ23ᐳ[27]<br />1: <br />ᐳ: 22, 28, 58<br />2: PgSelect[29], PgSelect[73]<br />ᐳ: 62, 63, 65, 66, 68, 69, 71, 72, 74, 75, 76, 64, 70"):::bucket
classDef bucket3 stroke:#ffa500
class Bucket3,PgClassExpression22,PgClassExpression28,PgSelect29,PgPageInfo57,First61,PgSelectSingle62,PgCursor63,PgClassExpression64,List65,Last67,PgSelectSingle68,PgCursor69,PgClassExpression70,List71,PgSelect72,First73,PgSelectSingle74,PgClassExpression75 bucket3
class Bucket3,PgClassExpression22,PgClassExpression28,PgSelect29,PgPageInfo58,First62,PgSelectSingle63,PgCursor64,PgClassExpression65,List66,Last68,PgSelectSingle69,PgCursor70,PgClassExpression71,List72,PgSelect73,First74,PgSelectSingle75,PgClassExpression76 bucket3
Bucket4("Bucket 4 (listItem)<br />Deps: 13<br /><br />ROOT __Item{4}ᐸ29ᐳ[30]"):::bucket
classDef bucket4 stroke:#0000ff
class Bucket4,__Item30,PgSelectSingle31 bucket4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,43 @@ graph TD
PgSelect10 ==> __Item14
PgSelectSingle15{{"PgSelectSingle[15∈1]<br />ᐸforumsᐳ"}}:::plan
__Item14 --> PgSelectSingle15
Constant58{{"Constant[58∈1] ➊<br />ᐸfalseᐳ"}}:::plan
Constant59{{"Constant[59∈1] ➊<br />ᐸfalseᐳ"}}:::plan
PgClassExpression16{{"PgClassExpression[16∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
PgSelectSingle15 --> PgClassExpression16
PgPageInfo57{{"PgPageInfo[57∈3] ➊"}}:::plan
Connection27 --> PgPageInfo57
First61{{"First[61∈3]"}}:::plan
Access78{{"Access[78∈3]<br />ᐸ14.1ᐳ"}}:::plan
Access78 --> First61
PgSelectSingle62{{"PgSelectSingle[62∈3]<br />ᐸmessagesᐳ"}}:::plan
First61 --> PgSelectSingle62
PgCursor63{{"PgCursor[63∈3]"}}:::plan
List65{{"List[65∈3]<br />ᐸ64ᐳ"}}:::plan
List65 --> PgCursor63
PgClassExpression64{{"PgClassExpression[64∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
PgSelectSingle62 --> PgClassExpression64
PgClassExpression64 --> List65
Last67{{"Last[67∈3]"}}:::plan
Access78 --> Last67
PgSelectSingle68{{"PgSelectSingle[68∈3]<br />ᐸmessagesᐳ"}}:::plan
Last67 --> PgSelectSingle68
PgCursor69{{"PgCursor[69∈3]"}}:::plan
List71{{"List[71∈3]<br />ᐸ70ᐳ"}}:::plan
List71 --> PgCursor69
PgClassExpression70{{"PgClassExpression[70∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
PgSelectSingle68 --> PgClassExpression70
PgClassExpression70 --> List71
First73{{"First[73∈3]"}}:::plan
Access79{{"Access[79∈3]<br />ᐸ14.2ᐳ"}}:::plan
Access79 --> First73
PgSelectSingle74{{"PgSelectSingle[74∈3]<br />ᐸmessagesᐳ"}}:::plan
First73 --> PgSelectSingle74
PgClassExpression75{{"PgClassExpression[75∈3]<br />ᐸcount(*)ᐳ"}}:::plan
PgSelectSingle74 --> PgClassExpression75
__Item14 --> Access78
PgPageInfo58{{"PgPageInfo[58∈3] ➊"}}:::plan
Connection27 --> PgPageInfo58
First62{{"First[62∈3]"}}:::plan
Access79{{"Access[79∈3]<br />ᐸ14.1ᐳ"}}:::plan
Access79 --> First62
PgSelectSingle63{{"PgSelectSingle[63∈3]<br />ᐸmessagesᐳ"}}:::plan
First62 --> PgSelectSingle63
PgCursor64{{"PgCursor[64∈3]"}}:::plan
List66{{"List[66∈3]<br />ᐸ65ᐳ"}}:::plan
List66 --> PgCursor64
PgClassExpression65{{"PgClassExpression[65∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
PgSelectSingle63 --> PgClassExpression65
PgClassExpression65 --> List66
Last68{{"Last[68∈3]"}}:::plan
Access79 --> Last68
PgSelectSingle69{{"PgSelectSingle[69∈3]<br />ᐸmessagesᐳ"}}:::plan
Last68 --> PgSelectSingle69
PgCursor70{{"PgCursor[70∈3]"}}:::plan
List72{{"List[72∈3]<br />ᐸ71ᐳ"}}:::plan
List72 --> PgCursor70
PgClassExpression71{{"PgClassExpression[71∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
PgSelectSingle69 --> PgClassExpression71
PgClassExpression71 --> List72
First74{{"First[74∈3]"}}:::plan
Access80{{"Access[80∈3]<br />ᐸ14.2ᐳ"}}:::plan
Access80 --> First74
PgSelectSingle75{{"PgSelectSingle[75∈3]<br />ᐸmessagesᐳ"}}:::plan
First74 --> PgSelectSingle75
PgClassExpression76{{"PgClassExpression[76∈3]<br />ᐸcount(*)ᐳ"}}:::plan
PgSelectSingle75 --> PgClassExpression76
__Item14 --> Access79
__Item30[/"__Item[30∈4]<br />ᐸ78ᐳ"\]:::itemplan
Access78 ==> __Item30
__Item14 --> Access80
__Item30[/"__Item[30∈4]<br />ᐸ79ᐳ"\]:::itemplan
Access79 ==> __Item30
PgSelectSingle31{{"PgSelectSingle[31∈4]<br />ᐸmessagesᐳ"}}:::plan
__Item30 --> PgSelectSingle31
PgSelect34[["PgSelect[34∈6]<br />ᐸusersᐳ"]]:::plan
Expand All @@ -86,9 +86,9 @@ graph TD
PgClassExpression47{{"PgClassExpression[47∈8]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
PgSelectSingle31 --> PgClassExpression47
PgSelectSingle54{{"PgSelectSingle[54∈8]<br />ᐸusersᐳ"}}:::plan
RemapKeys76{{"RemapKeys[76∈8]<br />ᐸ31:{”0”:3,”1”:4}ᐳ"}}:::plan
RemapKeys76 --> PgSelectSingle54
PgSelectSingle31 --> RemapKeys76
RemapKeys77{{"RemapKeys[77∈8]<br />ᐸ31:{”0”:3,”1”:4}ᐳ"}}:::plan
RemapKeys77 --> PgSelectSingle54
PgSelectSingle31 --> RemapKeys77
PgClassExpression55{{"PgClassExpression[55∈9]<br />ᐸ__users__.”username”ᐳ"}}:::plan
PgSelectSingle54 --> PgClassExpression55
PgClassExpression56{{"PgClassExpression[56∈9]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
Expand All @@ -102,14 +102,14 @@ graph TD
class Bucket0,__Value2,__Value4,PgSelect10,Access11,Access12,Object13,Connection27 bucket0
Bucket1("Bucket 1 (listItem)<br />Deps: 27, 13<br /><br />ROOT __Item{1}ᐸ10ᐳ[14]"):::bucket
classDef bucket1 stroke:#00bfff
class Bucket1,__Item14,PgSelectSingle15,Constant58 bucket1
Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 15, 27, 14, 13, 58<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[15]"):::bucket
class Bucket1,__Item14,PgSelectSingle15,Constant59 bucket1
Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 15, 27, 14, 13, 59<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[15]"):::bucket
classDef bucket2 stroke:#7f007f
class Bucket2,PgClassExpression16 bucket2
Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 27, 14, 13, 58<br /><br />ROOT Connectionᐸ23ᐳ[27]"):::bucket
Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 27, 14, 13, 59<br /><br />ROOT Connectionᐸ23ᐳ[27]"):::bucket
classDef bucket3 stroke:#ffa500
class Bucket3,PgPageInfo57,First61,PgSelectSingle62,PgCursor63,PgClassExpression64,List65,Last67,PgSelectSingle68,PgCursor69,PgClassExpression70,List71,First73,PgSelectSingle74,PgClassExpression75,Access78,Access79 bucket3
Bucket4("Bucket 4 (listItem)<br />Deps: 13<br /><br />ROOT __Item{4}ᐸ78ᐳ[30]"):::bucket
class Bucket3,PgPageInfo58,First62,PgSelectSingle63,PgCursor64,PgClassExpression65,List66,Last68,PgSelectSingle69,PgCursor70,PgClassExpression71,List72,First74,PgSelectSingle75,PgClassExpression76,Access79,Access80 bucket3
Bucket4("Bucket 4 (listItem)<br />Deps: 13<br /><br />ROOT __Item{4}ᐸ79ᐳ[30]"):::bucket
classDef bucket4 stroke:#0000ff
class Bucket4,__Item30,PgSelectSingle31 bucket4
Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 31, 13<br /><br />ROOT PgSelectSingle{4}ᐸmessagesᐳ[31]"):::bucket
Expand All @@ -123,7 +123,7 @@ graph TD
class Bucket7,PgClassExpression40,PgClassExpression41 bucket7
Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 31<br /><br />ROOT PgSelectSingle{4}ᐸmessagesᐳ[31]"):::bucket
classDef bucket8 stroke:#dda0dd
class Bucket8,PgCursor44,PgClassExpression45,List46,PgClassExpression47,PgSelectSingle54,RemapKeys76 bucket8
class Bucket8,PgCursor44,PgClassExpression45,List46,PgClassExpression47,PgSelectSingle54,RemapKeys77 bucket8
Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 54<br /><br />ROOT PgSelectSingle{8}ᐸusersᐳ[54]"):::bucket
classDef bucket9 stroke:#ff0000
class Bucket9,PgClassExpression55,PgClassExpression56 bucket9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ graph TD
PgSelect10 ==> __Item14
PgSelectSingle15{{"PgSelectSingle[15∈1]<br />ᐸforumsᐳ"}}:::plan
__Item14 --> PgSelectSingle15
Constant58{{"Constant[58∈1] ➊<br />ᐸfalseᐳ"}}:::plan
Constant59{{"Constant[59∈1] ➊<br />ᐸfalseᐳ"}}:::plan
PgClassExpression16{{"PgClassExpression[16∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
PgSelectSingle15 --> PgClassExpression16
PgSelect29[["PgSelect[29∈3]<br />ᐸmessagesᐳ"]]:::plan
PgClassExpression22{{"PgClassExpression[22∈3]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
PgClassExpression28{{"PgClassExpression[28∈3]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
Object13 & PgClassExpression22 & PgClassExpression28 & Connection27 --> PgSelect29
PgSelect60[["PgSelect[60∈3]<br />ᐸmessages(aggregate)ᐳ"]]:::plan
Object13 & PgClassExpression22 & PgClassExpression28 & Connection27 --> PgSelect60
PgSelect61[["PgSelect[61∈3]<br />ᐸmessages(aggregate)ᐳ"]]:::plan
Object13 & PgClassExpression22 & PgClassExpression28 & Connection27 --> PgSelect61
PgSelectSingle15 --> PgClassExpression22
PgSelectSingle15 --> PgClassExpression28
PgPageInfo57{{"PgPageInfo[57∈3] ➊"}}:::plan
Connection27 --> PgPageInfo57
First61{{"First[61∈3]"}}:::plan
PgSelect60 --> First61
PgSelectSingle62{{"PgSelectSingle[62∈3]<br />ᐸmessagesᐳ"}}:::plan
First61 --> PgSelectSingle62
PgClassExpression63{{"PgClassExpression[63∈3]<br />ᐸcount(*)ᐳ"}}:::plan
PgSelectSingle62 --> PgClassExpression63
PgPageInfo58{{"PgPageInfo[58∈3] ➊"}}:::plan
Connection27 --> PgPageInfo58
First62{{"First[62∈3]"}}:::plan
PgSelect61 --> First62
PgSelectSingle63{{"PgSelectSingle[63∈3]<br />ᐸmessagesᐳ"}}:::plan
First62 --> PgSelectSingle63
PgClassExpression64{{"PgClassExpression[64∈3]<br />ᐸcount(*)ᐳ"}}:::plan
PgSelectSingle63 --> PgClassExpression64
__Item30[/"__Item[30∈4]<br />ᐸ29ᐳ"\]:::itemplan
PgSelect29 ==> __Item30
PgSelectSingle31{{"PgSelectSingle[31∈4]<br />ᐸmessagesᐳ"}}:::plan
Expand Down Expand Up @@ -90,13 +90,13 @@ graph TD
class Bucket0,__Value2,__Value4,PgSelect10,Access11,Access12,Object13,Connection27 bucket0
Bucket1("Bucket 1 (listItem)<br />Deps: 13, 27<br /><br />ROOT __Item{1}ᐸ10ᐳ[14]"):::bucket
classDef bucket1 stroke:#00bfff
class Bucket1,__Item14,PgSelectSingle15,Constant58 bucket1
Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 15, 13, 27, 58<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[15]"):::bucket
class Bucket1,__Item14,PgSelectSingle15,Constant59 bucket1
Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 15, 13, 27, 59<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[15]"):::bucket
classDef bucket2 stroke:#7f007f
class Bucket2,PgClassExpression16 bucket2
Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 15, 13, 27, 58<br /><br />ROOT Connectionᐸ23ᐳ[27]<br />1: <br />ᐳ: 22, 28, 57<br />2: PgSelect[29], PgSelect[60]<br />ᐳ: 61, 62, 63"):::bucket
Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 15, 13, 27, 59<br /><br />ROOT Connectionᐸ23ᐳ[27]<br />1: <br />ᐳ: 22, 28, 58<br />2: PgSelect[29], PgSelect[61]<br />ᐳ: 62, 63, 64"):::bucket
classDef bucket3 stroke:#ffa500
class Bucket3,PgClassExpression22,PgClassExpression28,PgSelect29,PgPageInfo57,PgSelect60,First61,PgSelectSingle62,PgClassExpression63 bucket3
class Bucket3,PgClassExpression22,PgClassExpression28,PgSelect29,PgPageInfo58,PgSelect61,First62,PgSelectSingle63,PgClassExpression64 bucket3
Bucket4("Bucket 4 (listItem)<br />Deps: 13<br /><br />ROOT __Item{4}ᐸ29ᐳ[30]"):::bucket
classDef bucket4 stroke:#0000ff
class Bucket4,__Item30,PgSelectSingle31 bucket4
Expand Down
Loading

0 comments on commit 12c908f

Please sign in to comment.