[fix](partition_prune) Move the pruning of predicates that are always true after partition pruning into the PlanPostProcessor#63111
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
1 similar comment
|
run buildall |
|
run buildall |
|
run buildall |
TPC-H: Total hot run time: 29511 ms |
TPC-DS: Total hot run time: 170534 ms |
|
run buildall |
TPC-H: Total hot run time: 29722 ms |
TPC-DS: Total hot run time: 170733 ms |
FE Regression Coverage ReportIncrement line coverage |
|
run p0 |
|
I agree with the core idea: partition-prunable predicates should not be removed before MV rewrite, otherwise MV matching may see an incomplete query predicate set and produce an unsafe rewrite. One concern is where the deferred-removal state is stored. The current implementation records
Putting that proof in A cleaner structure may be to attach this information to the scan itself, e.g. class PartitionPruneInfo {
Set<Long> provedPartitionIds;
List<Slot> partitionSlots;
Set<Expression> prunableConjuncts;
}Then the post processor can simply inspect scan.getPartitionPruneInfo() and remove a conjunct only when: partitionPruneInfo.getProvedPartitionIds().containsAll(scan.getSelectedPartitionIds())This keeps the invariant local to the scan and avoids using StatementContext as a side table for plan-node-specific proof. |
…nstead of StatementContext ### What problem does this PR solve? Problem Summary: Move PartitionPrunablePredicate info from StatementContext (keyed by TableIdentifier) onto LogicalOlapScan / PhysicalOlapScan so it follows the scan through with*/deepCopy and is included in equals. Also propagate the info onto the MV scan rewritten by SyncMaterializationContext#getScanPlan so the post-processor can still strip the deferred conjuncts after sync MV rewrite. ### Release note None ### Check List (For Author) - Test: Regression test (prune_predicates_mv_test.groovy) - Behavior changed: No - Does this need documentation: No Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
One olap scan can carry at most one PartitionPrunablePredicate, so use Optional instead of Set. Simplifies merge in PruneOlapScanPartition and iteration in PrunePartitionPredicate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d817a84 to
4c371b5
Compare
|
run buildall |
TPC-H: Total hot run time: 29486 ms |
TPC-DS: Total hot run time: 169360 ms |
FE UT Coverage ReportIncrement line coverage |
|
run feut |
FE Regression Coverage ReportIncrement line coverage |
FE UT Coverage ReportIncrement line coverage |
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #57169
Problem Summary:
After partition pruning, predicates that are evaluated to constant true are removed as an optimization (introduced by #57169). However, this introduced a bug in materialized view rewriting: when such predicates are removed, they are not compensated above the rewritten materialized view. Since the materialized view itself is not partitioned, this leads to incorrect query results.
This PR fixes the issue by moving the removal of constant-true predicates to the planPostProcessors phase. This ensures that the predicate removal does not interfere with materialized view rewriting, preserving correctness while still retaining the optimization benefit.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)