Repository navigation
Conversation
PR Reviewer Guide 🔍(Review updated until commit 1a37aa3)Here are some key observations to aid the review process:
|
Split out to opensearch-project#5777; it is independent of request-level time bounds. Signed-off-by: Kai Huang <[email protected]>
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (63.17%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #5777 +/- ##
============================================
+ Coverage 62.84% 63.17% +0.32%
- Complexity 8777 8839 +62
============================================
Files 937 939 +2
Lines 40118 40349 +231
Branches 4516 4556 +40
============================================
+ Hits 25212 25489 +277
+ Misses 14106 14035 -71
- Partials 800 825 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4cf8d1e to
99e88a5
Compare
|
Persistent review updated to latest commit 99e88a5 |
99e88a5 to
12bd4cc
Compare
|
Persistent review updated to latest commit 12bd4cc |
PR Code Suggestions ✨Latest suggestions up to 1a37aa3 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit a5b5a15
Suggestions up to commit 672abde
Suggestions up to commit 03cf048
Suggestions up to commit 0953d84
Suggestions up to commit 04f8c59
|
12bd4cc to
0b57419
Compare
|
Persistent review updated to latest commit 0b57419 |
0b57419 to
04f8c59
Compare
|
Persistent review updated to latest commit 04f8c59 |
04f8c59 to
0953d84
Compare
|
Persistent review updated to latest commit 0953d84 |
0953d84 to
03cf048
Compare
|
Persistent review updated to latest commit 03cf048 |
03cf048 to
672abde
Compare
|
Persistent review updated to latest commit 672abde |
…esults Partial-result mode (opensearch-project#5657) narrows an aggregation to the index subset where its group fields are aggregatable. It decided per aggregation, so a plan grouping one scan more than once could pick two different subsets: the one response was then built from different sets of documents, and the two warnings differed in text so they could not be collapsed. chart and timechart are this shape by construction -- the charted rows plus a pass ranking the top-N columns -- as are append, appendcol, multisearch, join and subqueries over aggregating subsearches. appendcol was the worst: it zips the two aggregations into one row, so a count from one subset sat beside a label ranked over another, and the row looked fine. Rather than skip partial mode for those queries, narrow every aggregate over a scan to a single shared subset: the indices aggregatable for the union of all their group fields. ScanAggregates resolves that union once per scan at compile time, via column origins so it survives projects and casts, and pushdown narrows every aggregate to it. Because the subset is shared, the response is drawn from one population and carries one warning. chart and timechart now get the partial-result speedup too, instead of always paying the full scan. When no index is aggregatable for the whole union, plan() returns null and the complete result is returned -- never an empty one. A group key with no traceable origin, or any failure in the analysis, bars partial mode for the scan, so the fallback is always the complete result. The union is resolved in core (Calcite only) and the mapping-aware subset in the opensearch module, bridged by CalcitePlanContext, which carries the per-scan field sets on its ThreadLocalSnapshot so they survive the transport->worker handoff. Two fixes fall out. The warning sorts its group fields, so equivalent plan alternatives that differ only in key order render alike and de-duplicate. And buildResultSet drains warnings before the timewrap pivot, whose finally clears the lifecycle signals -- otherwise a narrowed timechart followed by timewrap would lose its PARTIAL_RESULT warning. Signed-off-by: Kai Huang <[email protected]>
672abde to
a5b5a15
Compare
|
Persistent review updated to latest commit a5b5a15 |
The dashboards search path attaches a request-body highlight to every query. On an aggregating query that highlight adds a synthetic _highlight column (type ANY) to the scan, which defeats RelMetadataQuery.getColumnOrigins for the group keys. ScanAggregates.analyze can then no longer trace any group key, fails closed, and bars every multi-aggregate plan (chart, timechart, appendcol) from partial-result narrowing -- so the query silently returns the complete result over all indices with no PARTIAL_RESULT warning (no banner), while single-aggregate queries keep warning. Aggregate pushdown itself is unaffected; the engine already drops the highlight on the size:0 request. A highlight is meaningless once rows collapse into aggregate buckets, so drop it when the plan aggregates. Origin tracing then succeeds, the shared index subset is computed, and the warning is emitted as before -- for every client, not just the dashboards. This also stops sending a redundant highlight the engine was discarding anyway. Adds chart- and timechart-with-highlight regression tests to CalcitePartialResultOnMappingConflictIT. Signed-off-by: Kai Huang <[email protected]>
|
Persistent review updated to latest commit 1a37aa3 |
|
closing this PR as the partial_result feature will be kept as experimental |
Description
Partial-result mode (#5657) narrows an aggregation to the index subset where its group fields are aggregatable. It decided per aggregation, so a plan grouping one scan more than once could pick two different subsets — one response built from different sets of documents, with two warnings whose text differed so
drainWarnings().distinct()couldn't collapse them.envis bare text in index C,svcis bare text in index B, both aggregatable in A:appendcolwas the worst: it zips the two aggregations into one row, so[5, "bx", "ay"]paired a count from {A,B} with a label ranked over {A,C} — a row describing documents that don't exist.Fix
Narrow every aggregate over a scan to one shared subset: the indices aggregatable for the union of all their group fields.
Because the subset is the union,
chart(env + ts) drops only the index whereenvis bad;appendcolby env / by svc drops any index where either is bad. Every aggregation over the scan sees the same indices, so the response can't mix populations.At a glance, one query end to end:
Two steps because (1) must see the whole plan (only place all aggregates are visible) but lives in
core, which cannot read index mappings; (2) lives inopensearch, which can. The thread-local carries the field list between them.Split across the module boundary:
How every case resolves:
stats,chart limit=0)analyzereturnsEMPTY; per-aggregate pushdown, unchanged from #5657chart,timechart,append/appendcol,multisearch, join / subquery over aggregating subsearches)plan()→ null → complete result over all indices, no warning — never emptyplan()→ null (nothing excluded) → normal pushdown, no warningkeywordvsinteger, two numerics)plan()→ null → complete result, deferred to #5610partial_resultdisabledThe walk runs once per compile, in
OpenSearchRelRunners.runjust beforeprepareStatement, and is skipped entirely for response formats with no warnings channel. Since #5646 a text/keyword conflict pushes down as a_sourcescript rather than failing, so every "complete" fallback above is correct — just slower.Two fixes fall out:
[env, ts]vs[ts, env]) render alike and de-duplicate.buildResultSetdrains warnings before the timewrap pivot, whosefinallyclears the lifecycle signals. A narrowedtimechart | timewrapwould otherwise lose itsPARTIAL_RESULTwarning — silent partial data, exactly what the channel exists to prevent. (Latent before this PR; reachable now thattimechartnarrows.)Behaviour
Fixture:
envbare text in one index,svcbare text in another, both aggregatable in a third.partial_resulton. All rows verified coherent on a live cluster.chart count() over ts by envtimechart span=1h count() by env... | append [ ... by svc ]... | appendcol [ ... by svc ][5,bx,ay]lie)multisearch [by env] [by svc]join/in-subquery / chart-in-subsearchstats count() by envstats | stats,addcoltotals,streamstatsThe substantive change vs. main: those queries no longer mix populations or emit duplicate banners; and vs. the gate:
chart/timechartget the partial-result speedup back.Testing
CalcitePartialResultOnMappingConflictIT— 31/31 on a live cluster. The multi-aggregation cases assert exactly one warning and that no value living only in an excluded index appears (proof of one coherent population); a concurrency test fires 12 interleaved chart/svc-stats queries and asserts each sees its own subset.ScanAggregatesTest,CalcitePPLScanAggregateShapeTest— the structural walk (DAG identity-dedup, ungrouped/no-scan aggregates don't count, fail-closed).PartialResultAggregatePushdownTest— warning text is independent of group-key order.PartialResultGateTest— the per-query info is derived per compile and doesn't leak across pooled-thread queries.core/opensearch/pplunit suites,CalciteChartCommandIT,CalciteTimechartCommandIT— green.Related Issues
Follows up #5657.
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.