Commit f1cbbba
[analytics-engine] Fix redundant instructions in FragmentConversionDriver (opensearch-project#21618)
* Remove final-agg special case in FragmentConversionDriver
The dedicated FINAL-aggregate branch was forcing an AggregateMode override that
diverged from the standard partial/final path, producing the cnt[count] Int32
vs Int64 mismatch downstream. FragmentConversionDriver now treats aggregate
fragments via the same conversion path as the rest, letting the decomposition
resolver + Calcite's reduce rule carry the types through correctly.
Follow-on adjustments:
- FUNCTIONS_TO_REDUCE expanded to {AVG, STDDEV_POP, VAR_POP}; STDDEV_SAMP/VAR_SAMP
excluded because the CASE-WHEN boolean guard defeats stripAnnotations.
- POWER added to BASELINE_SCALAR_OPS (emitted as final sqrt).
- IT coverage for all four stat aggs in StreamingCoordinatorReduceIT.
- Existing planner tests updated for the new post-reduction pipeline shape.
Signed-off-by: Marc Handalian <marc.handalian@gmail.com>
* fix(qa,planner): enable STDDEV_SAMP/VAR_SAMP, drop partial-agg instruction, test cleanups
Follow-up to Marc Handalian's commit that removed the FINAL-aggregate special case
in FragmentConversionDriver.
FragmentConversionDriver:
- Drop the PARTIAL-aggregate instruction emission too. The Calcite-layer split
(OpenSearchAggregateSplitRule + AggregateDecompositionResolver) already produces
properly decomposed PARTIAL and FINAL fragments; the shard-side mode-forcing via
NativeBridge.preparePartialPlan → force_aggregate_mode(Partial) was belt-and-
suspenders. With it removed, every fragment takes the same executeLocalPlan path
and DataFusion handles its own Final(Partial(...)) pair — correctness preserved
because every aggregate reaching either stage is associative (SUM/MIN/MAX, COUNT
function-swapped to SUM, HLL sketch merge, AVG/STDDEV primitive-decomposed).
The downstream Java and Rust machinery (PartialAggregateInstructionHandler,
FinalAggregateInstructionHandler, prepareFinalPlan FFI, force_aggregate_mode)
stays in place — dormant, not dead — ready for re-enablement once upstream
DataFusion's substrait consumer respects aggregation_phase (see
.kiro/docs/datafusion-upstream-aggregation-phase.md).
OpenSearchAggregateReduceRule:
- FUNCTIONS_TO_REDUCE expanded to the full statistical set
{AVG, STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP}.
- Javadoc updated to reflect the full reduction set and explain why STDDEV_SAMP/
VAR_SAMP now flow through (Bessel's-correction CASE guard uses comparison
operators that joined BASELINE_SCALAR_OPS in this commit).
OpenSearchProjectRule:
- Added the six SQL comparison operators (>, >=, <, <=, =, !=) to
BASELINE_SCALAR_OPS. They are emitted by Calcite's reduce rule for the SAMP-
variant Bessel's-correction guard and are SQL-execution primitives every
backend supports natively — consistent with the existing baseline rationale.
StreamingCoordinatorReduceIT:
- Add missing semicolon at testAvgAcrossShards (int total = NUM_SHARDS *
DOCS_PER_SHARD). The standard integTest task excludes this class via a glob,
so the build failure only surfaced under integTestStreaming.
- Remove the @AwaitsFix on testStddevSampAcrossShards and testVarSampAcrossShards
(now enabled by the FUNCTIONS_TO_REDUCE and BASELINE_SCALAR_OPS changes above);
drop the now-unused AwaitsFix import.
AppendPipeCommandIT:
- Replace fully-qualified java.util.* references in testAppendPipeSort with
imported short forms; add HashMap and Set imports. Matches the rest of the file.
Verified locally (after rebuilding the Rust dylib against the Wave A UDF set):
- :sandbox:plugins:analytics-engine:test — 148 tests, 0 failures
- :sandbox:qa:analytics-engine-rest:integTest — 304 tests, 4 skipped, 0 failures
- :sandbox:qa:analytics-engine-rest:integTestStreaming — 7 tests, 0 skipped,
0 failures (both STDDEV_SAMP and VAR_SAMP tests active and green)
Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
---------
Signed-off-by: Marc Handalian <marc.handalian@gmail.com>
Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
Co-authored-by: Marc Handalian <marc.handalian@gmail.com>1 parent a02606f commit f1cbbba
10 files changed
Lines changed: 282 additions & 57 deletions
File tree
- sandbox
- plugins/analytics-engine/src
- main/java/org/opensearch/analytics/planner
- dag
- rules
- test/java/org/opensearch/analytics/planner
- dag
- qa/analytics-engine-rest/src/test/java/org/opensearch/analytics/qa
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | 137 | | |
143 | | - | |
144 | 138 | | |
145 | 139 | | |
146 | 140 | | |
| |||
Lines changed: 17 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
85 | 95 | | |
86 | 96 | | |
87 | 97 | | |
| |||
Lines changed: 17 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| 244 | + | |
| 245 | + | |
243 | 246 | | |
244 | 247 | | |
245 | | - | |
| 248 | + | |
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
249 | 252 | | |
250 | 253 | | |
251 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
252 | 257 | | |
253 | 258 | | |
254 | 259 | | |
255 | | - | |
256 | | - | |
| 260 | + | |
| 261 | + | |
257 | 262 | | |
258 | 263 | | |
259 | 264 | | |
260 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
261 | 273 | | |
262 | 274 | | |
263 | 275 | | |
| |||
Lines changed: 12 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
| 265 | + | |
| 266 | + | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
| 274 | + | |
| 275 | + | |
280 | 276 | | |
281 | 277 | | |
282 | 278 | | |
283 | 279 | | |
284 | 280 | | |
285 | | - | |
| 281 | + | |
286 | 282 | | |
287 | | - | |
| 283 | + | |
288 | 284 | | |
289 | 285 | | |
290 | 286 | | |
291 | 287 | | |
292 | 288 | | |
293 | | - | |
294 | | - | |
295 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
296 | 292 | | |
297 | 293 | | |
298 | | - | |
299 | | - | |
| 294 | + | |
| 295 | + | |
300 | 296 | | |
301 | 297 | | |
302 | 298 | | |
303 | | - | |
| 299 | + | |
304 | 300 | | |
305 | 301 | | |
306 | 302 | | |
| |||
Lines changed: 5 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 132 | + | |
135 | 133 | | |
136 | 134 | | |
137 | 135 | | |
| |||
Lines changed: 33 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 74 | + | |
72 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
73 | 96 | | |
74 | 97 | | |
75 | 98 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
131 | 130 | | |
132 | 131 | | |
133 | 132 | | |
134 | | - | |
135 | 133 | | |
136 | 134 | | |
137 | 135 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
68 | | - | |
69 | 67 | | |
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
76 | | - | |
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
80 | 77 | | |
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
84 | | - | |
85 | 81 | | |
86 | 82 | | |
87 | 83 | | |
| |||
0 commit comments