Skip to content

[core] Skip TopN pushdown when a non-partition filter is present#8458

Merged
JingsongLi merged 1 commit into
apache:masterfrom
plusplusjiajia:fix-topn-nonpartition-filter
Jul 4, 2026
Merged

[core] Skip TopN pushdown when a non-partition filter is present#8458
JingsongLi merged 1 commit into
apache:masterfrom
plusplusjiajia:fix-topn-nonpartition-filter

Conversation

@plusplusjiajia

Copy link
Copy Markdown
Member

Purpose

DataTableBatchScan.applyPushDownTopN prunes splits by the sort column's min/max stats, but a non-partition WHERE filter drops rows at read time, after pruning. A split kept for its stats may have its top rows filtered out, while a split holding the true post-filter top-N may be pruned and never read — so ORDER BY ... LIMIT can return wrong/missing rows.

Skip TopN pushdown when snapshotReader.hasNonPartitionFilter(), mirroring applyPushDownLimit (which already guards both this and the auth filter). Partition-only filters are unaffected, since all surviving rows pass and stats-based pruning stays valid.

applyPushDownTopN pruned splits by sort-column stats without checking a
non-partition WHERE filter, which removes rows after pruning, so it could keep
too few splits. Match applyPushDownLimit and skip pushdown when one is present.
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi JingsongLi merged commit c77405e into apache:master Jul 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants