You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "deepthi912 (via GitHub)" <gi...@apache.org> on 2026/03/18 15:55:20 UTC
Re: [PR] Add additional pruning step for Upsert Tables [pinot]
deepthi912 commented on code in PR #17898:
URL: https://github.com/apache/pinot/pull/17898#discussion_r2954485552
##########
pinot-core/src/main/java/org/apache/pinot/core/query/pruner/SegmentPrunerService.java:
##########
@@ -134,19 +136,31 @@ public List<IndexSegment> prune(List<IndexSegment> segments, QueryContext query,
*
* @param segments the list of segments to be pruned. This is a destructive operation that may modify this list in an
* undefined way. Therefore, this list should not be used after calling this method.
+ * @param query query context; when non-null and skipUpsert=true, segments with 0 valid docs are not treated as
+ * empty (they contribute replaced rows to the result).
* @return the new list with filtered elements. This is the list that have to be used.
*/
- private static List<IndexSegment> removeEmptySegments(List<IndexSegment> segments) {
+ private static List<IndexSegment> removeEmptySegments(List<IndexSegment> segments, @Nullable QueryContext query) {
int selected = 0;
for (IndexSegment segment : segments) {
- if (!isEmptySegment(segment)) {
+ if (!isEmptySegment(segment, query)) {
segments.set(selected++, segment);
}
}
return segments.subList(0, selected);
}
- private static boolean isEmptySegment(IndexSegment segment) {
- return segment.getSegmentMetadata().getTotalDocs() == 0;
+ private static boolean isEmptySegment(IndexSegment segment, @Nullable QueryContext query) {
+ if (segment.getSegmentMetadata().getTotalDocs() == 0) {
+ return true;
+ }
+ // For upsert tables, treat segments with 0 valid docs as empty only when the query does not skip upsert.
+ // When skipUpsert=true, the query returns all docs (including replaced), so the segment contributes rows.
+ // Use query options map directly: _skipUpsert is only set on the server; the broker has options in the map.
+ if (query != null && query.getQueryOptions() != null && QueryOptionsUtils.isSkipUpsert(query.getQueryOptions())) {
+ return false;
+ }
+ ThreadSafeMutableRoaringBitmap validDocIds = segment.getValidDocIds();
Review Comment:
Queryable docIds are not present for all upsert tables, all queryable docs will be handled under validDocs. So we should be good taking into account validDocs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org