This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.2 by this push:
     new d5a10807207 branch-4.2: [test](nereids) Set runningUnitTest in 
SqlTestBase to keep fixture partitions non-empty (#69881)
d5a10807207 is described below

commit d5a108072074d755f1dae093ae8668a74599ac13
Author: yujun <[email protected]>
AuthorDate: Mon Nov 2 09:16:06 2026 +0800

    branch-4.2: [test](nereids) Set runningUnitTest in SqlTestBase to keep 
fixture partitions non-empty (#69881)
    
    ### What problem does this PR solve?
    
    Problem Summary:
    
    `RelationImpliedPredicateTest` failed intermittently on the branch-4.2
    community FE unit test pipeline (a few failures out of a few hundred
    runs, only on the 8-fork CI runners). The failure showed the MV scan
    rewritten into an empty relation, the lower materialized view "rewritten
    but not chosen" because its cost was near zero, and the upper
    materialized view not rewritten ("the graph logic between query and view
    is not consistent").
    
    Root cause: `SqlTestBase` fixtures create tables and materialized views
    without loading data, so every partition stays at the initial visible
    version. Branch 4.2 does not set `FeConstants.runningUnitTest` in
    `SqlTestBase`, so `Partition.hasData()` reports these fixture partitions
    as empty and `PRUNE_EMPTY_PARTITION`, which is still enabled when
    materialized view candidate plans are replayed, rewrites the scans into
    empty relations. The 4.2 backport of the nested MV rewrite test worked
    around this by raising the partition visible version of the MV to fake a
    completed refresh, but the `BUILD IMMEDIATE` refresh runs asynchronously
    and a complete refresh uses `INSERT OVERWRITE`, which replaces the
    partition and resets its visible version to the initial value. When the
    refresh finished after the test had raised the version, the scan was
    pruned again and the test failed.
    
    This PR aligns `SqlTestBase` with master by setting
    `FeConstants.runningUnitTest` in `runBeforeAll`, so fixture partitions
    are treated as non-empty, and removes the artificial partition version
    bump from the test.
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test: Unit Test
        - `RelationImpliedPredicateTest` (12 cases)
    - Behavior changed: No (test-only change)
    - Does this need documentation: No
---
 .../apache/doris/nereids/mv/RelationImpliedPredicateTest.java  | 10 +++-------
 .../java/org/apache/doris/nereids/sqltest/SqlTestBase.java     |  2 ++
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/mv/RelationImpliedPredicateTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/mv/RelationImpliedPredicateTest.java
index 378fed01ec2..a012de72de1 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/mv/RelationImpliedPredicateTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/mv/RelationImpliedPredicateTest.java
@@ -20,7 +20,6 @@ package org.apache.doris.nereids.mv;
 import org.apache.doris.catalog.Database;
 import org.apache.doris.catalog.Env;
 import org.apache.doris.catalog.MTMV;
-import org.apache.doris.catalog.Partition;
 import org.apache.doris.common.jmockit.Deencapsulation;
 import org.apache.doris.mtmv.BaseTableInfo;
 import org.apache.doris.mtmv.MTMVCache;
@@ -604,13 +603,10 @@ public class RelationImpliedPredicateTest extends 
SqlTestBase {
 
     private void mockRefreshedPartitions(MTMV mtmv) {
         // Candidate validity alone does not model a completed refresh. 
Populate definition coverage
-        // and publish a data version so rewrite normalization does not prune 
the MV as empty.
+        // for every fixture partition, as addTaskResult does after successful 
refreshes.
         Map<String, MTMVRefreshPartitionSnapshot> snapshots = new HashMap<>();
-        for (Partition partition : mtmv.getPartitions()) {
-            long refreshVersion = partition.getNextVersion();
-            partition.setNextVersion(refreshVersion + 1);
-            partition.updateVisibleVersion(refreshVersion);
-            snapshots.put(partition.getName(), new 
MTMVRefreshPartitionSnapshot());
+        for (String partitionName : mtmv.getPartitionNames()) {
+            snapshots.put(partitionName, new MTMVRefreshPartitionSnapshot());
         }
         mtmv.getRefreshSnapshot().updateSnapshots(snapshots, 
mtmv.getPartitionNames());
         mtmv.invalidateRewriteCache();
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/sqltest/SqlTestBase.java 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/sqltest/SqlTestBase.java
index 1be34d85bef..d7fe87e81d8 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/nereids/sqltest/SqlTestBase.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/sqltest/SqlTestBase.java
@@ -19,6 +19,7 @@ package org.apache.doris.nereids.sqltest;
 
 import org.apache.doris.catalog.Env;
 import org.apache.doris.catalog.MetaIdGenerator.IdGeneratorBuffer;
+import org.apache.doris.common.FeConstants;
 import org.apache.doris.nereids.CascadesContext;
 import 
org.apache.doris.nereids.rules.exploration.mv.LogicalCompatibilityContext;
 import org.apache.doris.nereids.rules.exploration.mv.StructInfo;
@@ -32,6 +33,7 @@ import org.apache.doris.utframe.TestWithFeService;
 public abstract class SqlTestBase extends TestWithFeService implements 
MemoPatternMatchSupported {
     @Override
     protected void runBeforeAll() throws Exception {
+        FeConstants.runningUnitTest = true;
         createDatabase("test");
         connectContext.setDatabase("test");
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to