Fix #5114: preserve head/TopK semantics for sort-expression pushdown#5135
Fix #5114: preserve head/TopK semantics for sort-expression pushdown#5135penghuo wants to merge 4 commits intoopensearch-project:mainfrom
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds an early-return in SortExprIndexScanRule to skip pushdown when the Sort is an instance of Changes
Sequence Diagram(s)mermaid Note: rectangles use default styling; interactions focus on primary components and decision branch. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@songkant-aws Please take a look. |
opensearch/src/main/java/org/opensearch/sql/opensearch/planner/rules/SortExprIndexScanRule.java
Outdated
Show resolved
Hide resolved
|
@penghuo LGTM. Approved with non-blocking nitty comment. |
Signed-off-by: Peng Huo <penghuo@gmail.com>
Signed-off-by: Peng Huo <penghuo@gmail.com>
Signed-off-by: Peng Huo <penghuo@gmail.com>
Description
Fix issue #5114 where
headcould be lost on sort-expression plans, returning more rows than requested (for example:source=... | eval a = rand() | sort a | fields id | head 5).The fix updates
SortExprIndexScanRuleto avoid rewritingCalciteEnumerableTopKpaths that carry fetch semantics, and keeps limit pushdown on the logical scan path only when limit/offset are available. This preserves TopK semantics while still allowing safe sort-expression pushdown.Related Issues
#5114
Check List
--signoffor-s.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.