Repository navigation
Add an opt-in partial-result mode for aggregations on text/keyword mapping conflicts - #5657
Conversation
PR Reviewer Guide 🔍(Review updated until commit d647281)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to d647281 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 97aa640
Suggestions up to commit 3ffd741
Suggestions up to commit 77fa72d
Suggestions up to commit 0db5aa7
Suggestions up to commit cafac5f
|
|
Persistent review updated to latest commit dad3bb3 |
|
Persistent review updated to latest commit 078c949 |
|
Persistent review updated to latest commit 83fd527 |
|
Persistent review updated to latest commit 2a3eab8 |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit d647281.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Persistent review updated to latest commit 19b6187 |
|
Persistent review updated to latest commit 51220fe |
|
Performance benchmark: partial results vs. today vs. scripted text pushdown (#5646)Comparing three responses to the mapping-conflict PIT-exhaustion case (an aggregation groups on a field mapped
These do not compute the same thing, so every latency figure is paired with a completeness column. Test setup
Datasets (deterministic, seed = 42):
Conflict field for wide/small is a nested Latency p50 / p90 / p99 (ms)"Today" (A) has two modes on the same query, decided by whether the shard count exceeds
The "under limit" column used Completeness (sum of
|
| Dataset | A (complete) | B | C (partial) | C completeness |
|---|---|---|---|---|
| wide, nested field | 219,328 | 220,000 but 1 null bucket (grouping lost) |
200,000 | 91.2% |
| small, nested field | 40,000 | 40,000 but 1 null bucket |
20,000 | 50% |
| flat field | 40,000 | 40,000, 50 buckets (correct) | 20,000 | 50% |
Why the latencies differ (mechanism)
A leaves the aggregate above the scan (explain shows requestedTotalSize=2147483647): every matching document is streamed out of every shard over PIT cursors into the coordinator JVM and counted there — cost scales with document count. B and C fuse the aggregate into the scan (size=0), so the count runs inside each shard and only bucket results cross the wire — cost scales with bucket count, and no PIT is opened. B groups on a per-document _source script; C groups on native keyword doc values, which is why C stays ~2–5× ahead of B even where both push down.
Takeaways
- When it runs, C is fastest (~34× vs A, ~10× vs B on wide) — but that speed is the partial answer: it excludes the non-aggregatable indices. On wide that is an 8.8% undercount; where the text indices hold half the data, 50%. Always accompanied by the
PARTIAL_RESULTwarning. - In the low-PIT-budget regime, A fails outright (100% errors on wide). B and C never open a PIT.
- B is complete and PIT-free on flat fields and is the natural default there. On the nested dotted field, B in its current state grouped all documents into a single
nullbucket (complete count, grouping lost) — worth verifying whether the scripted_sourcereader resolves nested dotted paths. This PR's producer resolves the nested path.
C is intended as an opt-in escape hatch (default off) for the widest patterns / lowest PIT budgets where a knowingly-partial, clearly-warned answer is preferable to a slow scan or a 500 — complementary to, not competing with, a complete-answer pushdown fix.
Single-node, laptop-scale absolutes; the ratios and the PIT / completeness / error-rate columns are the transferable results.
|
The warning listed every group key rather than the fields that could not be aggregated, which made it both inaccurate and impossible to de-duplicate. Inaccurate because a key that is fine everywhere gets named as the problem: charting by a keyword field over a date produced "mapping conflict on [attributes.cluster, timestamp]" when the date was aggregatable in every index and nothing about it needed fixing. Impossible to de-duplicate because the planner raises this once per equivalent plan alternative -- which drainWarnings() collapses by value, and opensearch-project#5657 wrote it for exactly that -- but the group keys arrive in whatever order the alternative had them, so logically identical findings differed as strings and survived as separate banners. A single chart query showed three: Results exclude 1 of 2 indices due to a mapping conflict on [attributes.cluster, timestamp]. Results exclude 1 of 2 indices due to a mapping conflict on [timestamp, attributes.cluster]. Results exclude 1 of 2 indices due to a mapping conflict on [attributes.cluster]. Reporting only the offending fields makes those three identical, so the existing dedup collapses them to one, and the one that remains names what to fix. The list is sorted for the same reason the excluded-index list already is: so plan ordering cannot reach the text. Reproducible without index pruning involved -- a plain text/keyword conflict and `chart count() over ts by env` -- and verified against a cluster: three banners before, one after, naming [env] alone. Signed-off-by: Kai Huang <[email protected]>
@penghuo on opensearch-project#5766: why change this file, it seems unrelated -- is it absolutely needed, can we remove it? Removed. It is not needed here, and the reason I had for carrying it no longer holds. The three-banner behaviour it fixed is reproducible on main with pruning off and no bounds at all -- a text/keyword conflict plus `chart count() over ts by env` -- so this PR never caused it. I originally carried the fix because an earlier revision of this PR retained an index that did not map the time field, which gave the partial-result feature something to exclude and so surfaced the banners. That retention was reverted; without it, pruning only ever reduces the index count, and partial-result needs two disagreeing indices, so this change makes those warnings less likely rather than more. Kept as a patch for its own PR against opensearch-project#5657, where it can be reviewed on its merits: the warning names every group key rather than the ones that cannot be aggregated, which is both inaccurate and prevents drainWarnings() from de-duplicating repeated plan alternatives. Signed-off-by: Kai Huang <[email protected]>
Partial-result mode (opensearch-project#5657) narrows an aggregation to the index subset where its group fields are aggregatable. It decides per aggregation, so a plan holding two aggregations over scans can pick two different subsets: the one response is then built from different sets of documents, and the two warnings differ in text so they cannot be collapsed. chart and timechart are this shape by construction -- the charted rows plus a pass ranking the top-N columns -- which is how the divergence was found: the ranking was computed over keyword+mixed while the plotted rows came from keyword alone, so chart could select a column it then had nothing to draw in. The same shape is reachable from user syntax, with append, appendcol or multisearch over aggregating subsearches; appendcol is the worst of them, zipping the two aggregations into one row where a count from one subset sits beside a label from another. So gate on the plan shape rather than on a command: inspect the built plan once in CalciteToolsHelper.optimize, before pushdown rules run (they each see only their own subtree), and mark the query when more than one aggregate reads a scan directly. Pushdown reads the mark, which rides ThreadLocalSnapshot because it can run on the complex worker pool while the plan is built on sql-worker. Chained stats ... | stats ... keeps partial mode: the second aggregate reads the first, not the index. So does chart limit=0, which has no ranking pass. Also sort the group fields in the warning text. Equivalent plan alternatives can present the same keys in either order ([env, ts] versus [ts, env]), which rendered as two banners for one aggregation. Signed-off-by: Kai Huang <[email protected]>
Partial-result mode (opensearch-project#5657) narrows an aggregation to the index subset where its group fields are aggregatable. It decides per aggregation, so a plan holding two aggregations over scans can pick two different subsets: the one response is then built from different sets of documents, and the two warnings differ in text so they cannot be collapsed. chart and timechart are this shape by construction -- the charted rows plus a pass ranking the top-N columns -- which is how the divergence was found: the ranking was computed over keyword+mixed while the plotted rows came from keyword alone, so chart could select a column it then had nothing to draw in. The same shape is reachable from user syntax, with append, appendcol or multisearch over aggregating subsearches; appendcol is the worst of them, zipping the two aggregations into one row where a count from one subset sits beside a label from another. So gate on the plan shape rather than on a command. OpenSearchRelRunners .run inspects the plan just before prepareStatement -- the one gate every pushdown pass goes through, and where the whole plan is still in hand, unlike the rules themselves -- and marks the query when more than one aggregate reads a scan directly. Pushdown reads the mark and returns the complete result instead. The mark is part of ThreadLocalSnapshot so that restoring it clears the flag on a pooled complex-worker thread, the way clearTimewrapSignals does on sql-worker. Chained stats ... | stats ... keeps partial mode: the second aggregate reads the first, not the index. So does chart limit=0, which has no ranking pass. Also sort the group fields in the warning text. Equivalent plan alternatives can present the same keys in either order ([env, ts] versus [ts, env]), which rendered as two banners for one aggregation. Signed-off-by: Kai Huang <[email protected]>
Partial-result mode (opensearch-project#5657) narrows an aggregation to the index subset where its group fields are aggregatable. It decides per aggregation, so a plan holding two aggregations over scans can pick two different subsets: the one response is then built from different sets of documents, and the two warnings differ in text so they cannot be collapsed. chart and timechart are this shape by construction -- the charted rows plus a pass ranking the top-N columns -- which is how the divergence was found: the ranking was computed over keyword+mixed while the plotted rows came from keyword alone, so chart could select a column it then had nothing to draw in. The same shape is reachable from user syntax, with append, appendcol or multisearch over aggregating subsearches; appendcol is the worst of them, zipping the two aggregations into one row where a count from one subset sits beside a label from another. So gate on the plan shape rather than on a command. OpenSearchRelRunners .run inspects the plan just before prepareStatement -- the one gate every pushdown pass goes through, and where the whole plan is still in hand, unlike the rules themselves -- and marks the query when more than one aggregate reads a scan directly. Pushdown reads the mark and returns the complete result instead. The mark is part of ThreadLocalSnapshot so that restoring it clears the flag on a pooled complex-worker thread, the way clearTimewrapSignals does on sql-worker. The walk runs for every query, so it is iterative rather than recursive and a plan it cannot read counts as several: barring a partial result is the safe answer, and it matches how the pushdown itself already treats an unreadable mapping. Chained stats ... | stats ... keeps partial mode: the second aggregate reads the first, not the index. So does chart limit=0, which has no ranking pass. Also sort the group fields in the warning text. Equivalent plan alternatives can present the same keys in either order ([env, ts] versus [ts, env]), which rendered as two banners for one aggregation. Signed-off-by: Kai Huang <[email protected]>
Partial-result mode (opensearch-project#5657) narrows an aggregation to the index subset where its group fields are aggregatable. It decides per aggregation, so a plan with two aggregations over the index can pick two different subsets: the one response is then built from different sets of documents, and the two warnings differ in text so they cannot be collapsed. chart and timechart are this shape by construction -- the charted rows plus a pass ranking the top-N columns -- which is how the divergence was found: the ranking was computed over keyword+mixed while the plotted rows came from keyword alone, so chart could select a column it then had nothing to draw in. The same shape is reachable from user syntax, with append, appendcol or multisearch over aggregating subsearches; appendcol is the worst of them, zipping the two aggregations into one row where a count from one subset sits beside a label from another. So gate on the plan shape rather than on a command. ScanAggregates counts the grouped aggregates that can reach a scan, and a query holding more than one is refused partial mode and returns the complete result. Reaching the scan through another aggregate counts: chart ranks by re-aggregating its own output, which pushdown merges back into a second scan-level aggregation on a different key. An ungrouped aggregate does not count -- group keys are what partial mode partitions on -- which is what keeps chained stats ... | stats sum(c) and addcoltotals on the partial path. Both compile paths mark the plan, through CalciteToolsHelper .markScanAggregates: OpenSearchRelRunners.run for the PPL and SQL endpoints, UnifiedQueryCompiler for the unified one. The mark is derived per compile rather than latched, is part of ThreadLocalSnapshot so restoring it clears the flag on a pooled complex-worker thread, and is skipped for a response format that has no warnings channel, since only the partial-result path reads it. Plans are DAGs -- chart hands one aggregate to both its branches -- so nodes are walked by identity, or a shared aggregate would count once per path reaching it. The walk is iterative, and a plan it cannot read counts as several: barring a partial result is the safe answer. Also sort the group fields in the warning text. Equivalent plan alternatives can present the same keys in either order ([env, ts] versus [ts, env]), which rendered as two banners for one aggregation. Signed-off-by: Kai Huang <[email protected]>
Partial-result mode (opensearch-project#5657) narrows an aggregation to the index subset where its group fields are aggregatable. It decides per aggregation, so a plan with two aggregations over the index can pick two different subsets: the one response is then built from different sets of documents, and the two warnings differ in text so they cannot be collapsed. chart and timechart are this shape by construction -- the charted rows plus a pass ranking the top-N columns -- which is how the divergence was found: the ranking was computed over keyword+mixed while the plotted rows came from keyword alone, so chart could select a column it then had nothing to draw in. The same shape is reachable from user syntax, with append, appendcol or multisearch over aggregating subsearches; appendcol is the worst of them, zipping the two aggregations into one row where a count from one subset sits beside a label from another. So gate on the plan shape rather than on a command. ScanAggregates counts the grouped aggregates that can reach a scan, and a query holding more than one is refused partial mode and returns the complete result. Reaching the scan through another aggregate counts: chart ranks by re-aggregating its own output, which pushdown merges back into a second scan-level aggregation on a different key. An ungrouped aggregate does not count -- group keys are what partial mode partitions on -- which is what keeps chained stats ... | stats sum(c) and addcoltotals on the partial path. Both compile paths mark the plan, through CalciteToolsHelper .markScanAggregates: OpenSearchRelRunners.run for the PPL and SQL endpoints, UnifiedQueryCompiler for the unified one. The mark is derived per compile rather than latched, is part of ThreadLocalSnapshot so restoring it clears the flag on a pooled complex-worker thread, and is skipped for a response format that has no warnings channel, since only the partial-result path reads it. Plans are DAGs -- chart hands one aggregate to both its branches -- so nodes are walked by identity, or a shared aggregate would count once per path reaching it. The walk is iterative, and a plan it cannot read counts as several: barring a partial result is the safe answer. Also sort the group fields in the warning text. Equivalent plan alternatives can present the same keys in either order ([env, ts] versus [ts, env]), which rendered as two banners for one aggregation. Signed-off-by: Kai Huang <[email protected]>
…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]>
…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]>
…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]>
The warnings array has been part of the PPL JSON response since opensearch-project#5657 but was never described in the protocol reference. Document both types, when the field is present, and which formats carry it. Signed-off-by: Kai Huang <[email protected]>
The warnings array has been part of the PPL JSON response since opensearch-project#5657 but was never described in the protocol reference. Document both types, when the field is present, and which formats carry it. Signed-off-by: Kai Huang <[email protected]>
The warnings array has been part of the PPL JSON response since opensearch-project#5657 but was never described in the protocol reference. Document both types, when the field is present, and which formats carry it. Signed-off-by: Kai Huang <[email protected]>
The warnings array has been part of the PPL JSON response since opensearch-project#5657 but was never described in the protocol reference. Document both types, when the field is present, and which formats carry it. Signed-off-by: Kai Huang <[email protected]>
The mode (opensearch-project#5657) narrowed an aggregation to the index subset where the group field is aggregatable and labelled the result with a warning. It is being dropped: returning a knowingly incomplete answer to make a query faster is the wrong default to offer, and gating it on a cluster setting, a per-request flag and a response-format check made three moving parts that each had to survive the security plugin's transport-to-worker handoff (opensearch-project#5739, opensearch-project#5743, opensearch-project#5758). Removed: PartialResultAggregatePushdown and its hook in CalciteLogicalIndexScan, plugins.query.partial_result.on_mapping_conflict.enabled, the per-request partial_result field, and the warnings-supported format gate that existed only to protect this feature. A conflicted aggregation once again returns the complete result over every index, which since opensearch-project#5646 pushes down as a _source script rather than failing. Kept whole: the warnings channel it introduced -- Warning, QueryResponse.warnings, CalcitePlanContext.addWarning/drainWarnings, and the SimpleJsonResponseFormatter plumbing. Nothing produces a warning after this commit; opensearch-project#5807 is the next producer, reporting a search that covered only some of its shards. Note for reviewers: dropping partial_result from TransportPPLQueryRequest changes that request's wire format. The class version-gates nothing and the field was appended the same way in 3.9, so this is symmetric with how it arrived, but it does mean a mixed 3.9/3.10 cluster must not route PPL across versions. Signed-off-by: Kai Huang <[email protected]>
* Remove the opt-in partial-result mode for mapping conflicts The mode (#5657) narrowed an aggregation to the index subset where the group field is aggregatable and labelled the result with a warning. It is being dropped: returning a knowingly incomplete answer to make a query faster is the wrong default to offer, and gating it on a cluster setting, a per-request flag and a response-format check made three moving parts that each had to survive the security plugin's transport-to-worker handoff (#5739, #5743, #5758). Removed: PartialResultAggregatePushdown and its hook in CalciteLogicalIndexScan, plugins.query.partial_result.on_mapping_conflict.enabled, the per-request partial_result field, and the warnings-supported format gate that existed only to protect this feature. A conflicted aggregation once again returns the complete result over every index, which since #5646 pushes down as a _source script rather than failing. Kept whole: the warnings channel it introduced -- Warning, QueryResponse.warnings, CalcitePlanContext.addWarning/drainWarnings, and the SimpleJsonResponseFormatter plumbing. Nothing produces a warning after this commit; #5807 is the next producer, reporting a search that covered only some of its shards. Note for reviewers: dropping partial_result from TransportPPLQueryRequest changes that request's wire format. The class version-gates nothing and the field was appended the same way in 3.9, so this is symmetric with how it arrived, but it does mean a mixed 3.9/3.10 cluster must not route PPL across versions. Signed-off-by: Kai Huang <[email protected]> * Drop the per-index mapping retention the feature needed getIndexMappings() on OpenSearchIndex and lastIndexMappings on the describe request existed only so the partitioner could see which index mapped a field which way. Nothing reads them now. The deep copy before merging stays: MergeRuleHelper rewrites the accumulated type's properties in place, so a fetched mapping would otherwise stop describing its own index. Its test now asserts that on the fetched mappings directly rather than through the removed accessor. Signed-off-by: Kai Huang <[email protected]> --------- Signed-off-by: Kai Huang <[email protected]>
The warnings array has been part of the PPL JSON response since opensearch-project#5657 but was never described in the protocol reference. Document both types, when the field is present, and which formats carry it. Signed-off-by: Kai Huang <[email protected]>
The warnings array has been part of the PPL JSON response since opensearch-project#5657 but was never described in the protocol reference. Document the PARTIAL_RESULT type, when the field is present, and which formats carry it. Signed-off-by: Kai Huang <[email protected]>
The warnings array has been part of the PPL JSON response since opensearch-project#5657 but was never described in the protocol reference. Document the PARTIAL_RESULT type, when the field is present, and which formats carry it. Signed-off-by: Kai Huang <[email protected]>
…ch-project#5814) * Remove the opt-in partial-result mode for mapping conflicts The mode (opensearch-project#5657) narrowed an aggregation to the index subset where the group field is aggregatable and labelled the result with a warning. It is being dropped: returning a knowingly incomplete answer to make a query faster is the wrong default to offer, and gating it on a cluster setting, a per-request flag and a response-format check made three moving parts that each had to survive the security plugin's transport-to-worker handoff (opensearch-project#5739, opensearch-project#5743, opensearch-project#5758). Removed: PartialResultAggregatePushdown and its hook in CalciteLogicalIndexScan, plugins.query.partial_result.on_mapping_conflict.enabled, the per-request partial_result field, and the warnings-supported format gate that existed only to protect this feature. A conflicted aggregation once again returns the complete result over every index, which since opensearch-project#5646 pushes down as a _source script rather than failing. Kept whole: the warnings channel it introduced -- Warning, QueryResponse.warnings, CalcitePlanContext.addWarning/drainWarnings, and the SimpleJsonResponseFormatter plumbing. Nothing produces a warning after this commit; opensearch-project#5807 is the next producer, reporting a search that covered only some of its shards. Note for reviewers: dropping partial_result from TransportPPLQueryRequest changes that request's wire format. The class version-gates nothing and the field was appended the same way in 3.9, so this is symmetric with how it arrived, but it does mean a mixed 3.9/3.10 cluster must not route PPL across versions. Signed-off-by: Kai Huang <[email protected]> * Drop the per-index mapping retention the feature needed getIndexMappings() on OpenSearchIndex and lastIndexMappings on the describe request existed only so the partitioner could see which index mapped a field which way. Nothing reads them now. The deep copy before merging stays: MergeRuleHelper rewrites the accumulated type's properties in place, so a fetched mapping would otherwise stop describing its own index. Its test now asserts that on the fetched mappings directly rather than through the removed accessor. Signed-off-by: Kai Huang <[email protected]> --------- Signed-off-by: Kai Huang <[email protected]> (cherry picked from commit 6d666ba) Signed-off-by: Kai Huang <[email protected]>
…5865) * Remove the opt-in partial-result mode for mapping conflicts The mode (#5657) narrowed an aggregation to the index subset where the group field is aggregatable and labelled the result with a warning. It is being dropped: returning a knowingly incomplete answer to make a query faster is the wrong default to offer, and gating it on a cluster setting, a per-request flag and a response-format check made three moving parts that each had to survive the security plugin's transport-to-worker handoff (#5739, #5743, #5758). Removed: PartialResultAggregatePushdown and its hook in CalciteLogicalIndexScan, plugins.query.partial_result.on_mapping_conflict.enabled, the per-request partial_result field, and the warnings-supported format gate that existed only to protect this feature. A conflicted aggregation once again returns the complete result over every index, which since #5646 pushes down as a _source script rather than failing. Kept whole: the warnings channel it introduced -- Warning, QueryResponse.warnings, CalcitePlanContext.addWarning/drainWarnings, and the SimpleJsonResponseFormatter plumbing. Nothing produces a warning after this commit; #5807 is the next producer, reporting a search that covered only some of its shards. Note for reviewers: dropping partial_result from TransportPPLQueryRequest changes that request's wire format. The class version-gates nothing and the field was appended the same way in 3.9, so this is symmetric with how it arrived, but it does mean a mixed 3.9/3.10 cluster must not route PPL across versions. * Drop the per-index mapping retention the feature needed getIndexMappings() on OpenSearchIndex and lastIndexMappings on the describe request existed only so the partitioner could see which index mapped a field which way. Nothing reads them now. The deep copy before merging stays: MergeRuleHelper rewrites the accumulated type's properties in place, so a fetched mapping would otherwise stop describing its own index. Its test now asserts that on the fetched mappings directly rather than through the removed accessor. --------- (cherry picked from commit 6d666ba) Signed-off-by: Kai Huang <[email protected]>
…indices (#482) OpenSearch 3.9.0 ships opensearch-project/sql#5657, which made wildcard PPL/SQL queries throw UnsupportedOperationException when one index maps an empty object and a sibling index maps a leaf under the same path. After the first rollover of otel-v1-apm-span, events.attributes is an empty object in the new index, so every query on otel-v1-apm-span-* can fail, including Agent Traces. The fix (opensearch-project/sql#5791) was backported to 3.9 in opensearch-project/sql#5864 and is in the 3.9.1 staging image. OpenSearch Dashboards stays on 3.9.0. Signed-off-by: Kyle Hounslow <[email protected]>
Description
On the Calcite PPL path, an aggregation grouped on a field that is mapped
keywordin some indices of a wildcard pattern andtextin others cannot use native pushdown. The multi-index type merge collapses the field totext-without-.keyword, which has no doc values, so the aggregation runs as a per-document_sourcescript over every document — correct, but a full-index scan that is orders of magnitude slower on a wide pattern.This PR adds an opt-in mode that returns a fast, partial answer instead: it aggregates over only the subset of indices where the field is natively aggregatable (
keyword) and attaches a warning naming the ones it excluded.So the choice becomes complete-but-slow (default) vs fast-but-partial (opt-in) — both correct, differing in coverage and speed.
How it works
warnings: [{type, message, detail}]array, emitted only when non-empty (existing responses are byte-for-byte unchanged):PartialResultAggregatePushdown). When the mode is on and the group key is a text/keyword conflict, the scan is narrowed to the aggregatable index subset and the aggregation pushed down over just that subset (size = 0, no PIT). The partitioning logic is unit-tested in isolation.partial_resultboolean in the query body (mirroringprofile) overrides the cluster setting for one query; absent → cluster setting decides.Behavior
Cluster setting
plugins.query.partial_result.on_mapping_conflict.enabled(defaultfalse):stats count() by <conflict field>_sourcescan of all docs)keywordsubset +PARTIAL_RESULTwarningformat=csvKey points
warnings, so CSV/RAW/VIZ fall through to the complete result rather than dropping data unannounced.keywordgroup whenever one exists; otherwise thetext-with-.keywordgroup; always exclude baretext. The result never depends on how many indices of each type match.Not in scope: recovering an excluded but aggregatable group (
text-with-.keywordalongside akeywordgroup) — that needs a per-group split-and-union, a larger separate change. This is why the warning recommends mapping the field askeywordeverywhere.Related Issues
Check List
docs/user/admin/settings.rst).--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.