From 43b99ddd7a346b5a936bddfcdf7b56b40c370d3b Mon Sep 17 00:00:00 2001 From: seawinde Date: Wed, 25 Jun 2025 14:50:47 +0800 Subject: [PATCH] [fix](mtmv) Fix compensate union all wrongly when partition mv use partition external table (#52218) Fix compensate union all wrongly when partition mv use partition external table in test mv/external_table/part_partition_invalid.groovy order_qt_after_modify_data_and_refresh_catalog data should be as following: ``` 1 2 1 2023-10-17 2023-10-17 2 2 2 2023-10-18 2023-10-18 3 2 3 2023-10-19 2023-10-19 ``` ### What problem does this PR solve? Issue Number: close #xxx Related PR: #49514 Problem Summary: ### Release note None ### Check List (For Author) - Test - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [x] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason - Behavior changed: - [ ] No. - [ ] Yes. - Does this need documentation? - [ ] No. - [ ] Yes. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label --- .../nereids/rules/exploration/mv/PartitionCompensator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/PartitionCompensator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/PartitionCompensator.java index 0ee88ce82a..ecb3c1d6cb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/PartitionCompensator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/PartitionCompensator.java @@ -85,8 +85,10 @@ public class PartitionCompensator { } MTMVPartitionInfo mvCustomPartitionInfo = mtmv.getMvPartitionInfo(); BaseTableInfo relatedPartitionTable = mvCustomPartitionInfo.getRelatedTableInfo(); - if (relatedPartitionTable == null || queryUsedBaseTablePartitionNameSet.isEmpty()) { + if (relatedPartitionTable == null || queryUsedBaseTablePartitionNameSet.isEmpty() + || !relatedPartitionTable.isInternalTable()) { // if mv is not partitioned or query not query any partition, doesn't compensate + // in 2.1, external table should not compensate union all return Pair.of(ImmutableMap.of(), ImmutableMap.of()); } Collection mvValidPartitions = cascadesContext.getStatementContext()