[analytics-engine] Per-shard bucket oversampling for TopK aggregation queries#21775
Conversation
PR Reviewer Guide 🔍(Review updated until commit e770031)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to e770031 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit ba0d773
Suggestions up to commit e27e229
Suggestions up to commit 1f61124
Suggestions up to commit 88fb3bb
Suggestions up to commit d462415
|
|
❌ Gradle check result for 3d360bb: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit b49b5a9 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21775 +/- ##
============================================
+ Coverage 73.42% 73.52% +0.10%
- Complexity 75503 75564 +61
============================================
Files 6034 6034
Lines 342661 342661
Branches 49294 49294
============================================
+ Hits 251584 251927 +343
+ Misses 71063 70710 -353
- Partials 20014 20024 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Persistent review updated to latest commit 2ab802d |
|
❌ Gradle check result for 2ab802d: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit 76d9b60 |
|
Persistent review updated to latest commit ff75c9d |
|
Persistent review updated to latest commit 4c9337d |
|
Persistent review updated to latest commit 475fc9f |
|
Persistent review updated to latest commit 4fba1aa |
expani
left a comment
There was a problem hiding this comment.
Thanks for the changes @sandeshkr419
Dropping some early comments, still going through the PR.
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit e770031.
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 9f92e07 |
|
❌ Gradle check result for 9f92e07: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit 1f61124 |
|
Persistent review updated to latest commit e27e229 |
expani
left a comment
There was a problem hiding this comment.
Thanks @sandeshkr419 it was fun iterating on this offline.
Really appreciate you sticking to the architecture and design intentions 🫡
Have a few comments around a few oddities that should be quick.
AnalyticsApproximationSettings with index.analytics.shard_bucket_oversampling_factor (double, default 1.5, dynamic). Registered in AnalyticsPlugin.getSettings(). OpenSearchSort gains perPartition flag for shard-local sort. Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
…te TopK Generic scalar UDF that evaluates opaque aggregate partial state to produce a sortable scalar. Takes (agg_name, state_binary) and dispatches to the accumulator's merge_batch+evaluate. Currently supports approx_distinct. Used by the TopK rewriter's reduce Project in substrait. Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
…+ Isthmus binding) Declare REDUCE_EVAL_OP SqlFunction, add to ADDITIONAL_SCALAR_SIGS for Isthmus substrait binding, and YAML entry for substrait extension. Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
…ertion) Post-CBO rewriter that finds bottommost Sort with collation above a grouped FINAL→ER→PARTIAL chain, reads oversampling factor from index setting, and inserts a per-partition Sort(fetch=shardSize) between PARTIAL and ER. Default factor=0 (disabled); set index.analytics.shard_bucket_oversampling_factor > 0 to enable. Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
|
❕ Gradle check result for ba0d773: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
Integration tests for TopK per-shard oversampling: sum+sort+head, count+sort+head, and factor=0 (disabled). Verifies correct results with 2-shard parquet-backed index. Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
|
Persistent review updated to latest commit e770031 |
… queries (opensearch-project#21775) Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
Description:
Adds a post-CBO rewriter that inserts a per-partition Sort+Limit between PARTIAL aggregate and ExchangeReducer, so each shard only ships top-N×factor groups instead of all groups.
Tests: TopKRewriterPlanShapeTests (2), ShardBucketOversamplingIT (7 on ClickBench multi-shard), reduce_eval, Rust unit test.
Check List
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.