You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serialize missing field createDefaultIfEmpty into streaming aggregate plan continuations (#3211)
There is missing state that was introduced to the `AggregateCursor` and
its accompanying plan in #3092. However, this state was not added to the
continuation, which results in unexpected behavior when we try to
deserialize the plan's continuation (effectively, it reverts to the old
behavior of the plan operator). We were already correctly
_de_serializing this information, so the upshot is that any plan that is
started after this current version should exhibit the correct behavior,
but we get incorrect behavior when a plan is started on an older
version.
This fixes#3096. I was able to get test coverage of this part of the
code by enabling `FORCE_CONTINUATIONS` mode on `aggregateIndexTests`.
Copy file name to clipboardexpand all lines: fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryStreamingAggregationPlan.java
+2-1
Original file line number
Diff line number
Diff line change
@@ -370,7 +370,8 @@ public PRecordQueryStreamingAggregationPlan toProto(@Nonnull final PlanSerializa
- query: select min(col3) from T2 group by col1, col2;
162
+
- supported_version: !current_version
150
163
- explain: "ISCAN(MV2 <,>) | MAP (_ AS _0) | AGG (min_l(_._0.COL3) AS _0) GROUP BY (_._0.COL1 AS _0, _._0.COL2 AS _1) | MAP (_._1._0 AS _0)"
151
164
- result: [{!l 1}, {!l 2}, {!l 3}]
165
+
-
166
+
- query: select min(col3) from T2 group by col1, col2;
167
+
# Cannot use FORCE_CONTINUATIONS with older versions due to: https://github.com/FoundationDB/fdb-record-layer/issues/3096
168
+
# (Extra values being produced after exhausting source of an aggregate cursor)
169
+
# Can remove once we do not care about backwards compatibility before !current_version
170
+
- maxRows: 1
171
+
- initialVersionLessThan: !current_version
172
+
# Different (incorrect) behavior for different past versions
173
+
- initialVersionAtLeast: !current_version
174
+
- result: [{!l 1}]
175
+
- result: [{!l 2}]
176
+
- result: [{!l 3}]
177
+
- result: []
152
178
-
153
179
# this should use the aggregate index in the future, for now, it is using streaming aggregate
154
180
# over base table scan.
155
181
- query: select max(col2) from t2;
182
+
- supported_version: !current_version
156
183
- explain: "ISCAN(MV3 <,>) | MAP (_ AS _0) | AGG (max_l(_._0.COL2) AS _0) | ON EMPTY NULL | MAP (_._0._0 AS _0)"
157
184
- result: [{!l 2}]
185
+
-
186
+
- query: select max(col2) from t2;
187
+
# Cannot use FORCE_CONTINUATIONS with older versions due to: https://github.com/FoundationDB/fdb-record-layer/issues/3096
188
+
# (Extra values being produced after exhausting source of an aggregate cursor)
189
+
# Can remove once we do not care about backwards compatibility before !current_version
190
+
- supported_version: !current_version
191
+
- maxRows: 1
192
+
- initialVersionLessThan: !current_version
193
+
- result: [{!l 2}]
194
+
- result: [{!null _}]
195
+
- result: [{!l 2}] # ad infinitum
196
+
- initialVersionAtLeast: !current_version
197
+
- result: [{!l 2}]
198
+
- result: []
158
199
-
159
200
- query: select col1, sum(col2) from T1 USE INDEX (vi1) group by col1;
160
201
- explain: "ISCAN(VI1 <,>) | MAP (_ AS _0) | AGG (sum_l(_._0.COL2) AS _0) GROUP BY (_._0.COL1 AS _0) | MAP (_._0._0 AS COL1, _._1._0 AS _1)"
@@ -208,12 +249,28 @@ test_block:
208
249
-
209
250
# Permuted max index can also be used to evaluate other aggregate functions via aggregation and roll-up
210
251
- query: select col3, sum(col2) as s from t2 use index (mv9) where col1 = 1 group by col1, col3 order by col3 asc;
252
+
- supported_version: !current_version
211
253
- explain: "ISCAN(MV9 [EQUALS promote(@c20 AS LONG)]) | MAP (_ AS _0) | AGG (sum_l(_._0.COL2) AS _0) GROUP BY (_._0.COL1 AS _0, _._0.COL3 AS _1) | MAP (_._0._1 AS COL3, _._1._0 AS S)"
- query: select col3, sum(col2) as s from t2 use index (mv9) where col1 = 1 group by col1, col3 order by col3 desc;
264
+
- supported_version: !current_version
215
265
- explain: "ISCAN(MV9 [EQUALS promote(@c20 AS LONG)] REVERSE) | MAP (_ AS _0) | AGG (sum_l(_._0.COL2) AS _0) GROUP BY (_._0.COL1 AS _0, _._0.COL3 AS _1) | MAP (_._0._1 AS COL3, _._1._0 AS S)"
0 commit comments