Commit a925ea9
committed
topk: fix wrong results on non-unique order col
Every now and then, we would get incorrect results
when the query contains an order by on a non-unique column.
After dropping to m values (assuming m < k), we lookup the group
by key in the parent, sort the result set, skip the first m and take
k - m. That sounds reasonable when the order by is unique.
However, in the case of non-unique order by cols, the sort on the
result set doesn't guarantee that the top m records (which we skip)
match what we currently have in the node. This can cause
duplicates and ultimately incorrect state.
Change-Id: I119e0648ac6722bf57146af545e4172d9a72b7f5
Reviewed-on: https://gerrit.readyset.name/c/readyset/+/9689
Tested-by: Buildkite CI
Reviewed-by: Sidney Cammeresi <sac@readyset.io>1 parent fc35ec2 commit a925ea9
1 file changed
+10
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | 143 | | |
146 | 144 | | |
147 | 145 | | |
| |||
157 | 155 | | |
158 | 156 | | |
159 | 157 | | |
| 158 | + | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
172 | 169 | | |
173 | 170 | | |
174 | 171 | | |
| |||
0 commit comments