File tree Expand file tree Collapse file tree 3 files changed +488
-0
lines changed
Expand file tree Collapse file tree 3 files changed +488
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @electric-sql/d2mini ' : patch
3+ ---
4+
5+ fix a bug where groupBy would not remove a group if it's key was completely removed from the stream
Original file line number Diff line number Diff line change @@ -87,6 +87,17 @@ export function groupBy<
8787 // Then reduce to compute aggregates
8888 const reduced = withKeysAndValues . pipe (
8989 reduce ( ( values ) => {
90+ // Calculate total multiplicity to check if the group should exist
91+ let totalMultiplicity = 0
92+ for ( const [ _ , multiplicity ] of values ) {
93+ totalMultiplicity += multiplicity
94+ }
95+
96+ // If total multiplicity is 0 or negative, the group should be removed completely
97+ if ( totalMultiplicity <= 0 ) {
98+ return [ ]
99+ }
100+
90101 const result : Record < string , unknown > = { }
91102
92103 // Get the original key from first value in group
You can’t perform that action at this time.
0 commit comments