Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.google.common.collect.Sets;
import mockit.Mock;
import mockit.MockUp;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand All @@ -58,6 +59,21 @@
*/
public class OptimizeGetAvailableMvsTest extends SqlTestBase {

@Override
protected void runBeforeEach() throws Exception {
dropTestMvs();
}

@AfterEach
void dropTestMvsAfterEach() throws Exception {
dropTestMvs();
}

private void dropTestMvs() throws Exception {
dropMvByNereids("drop materialized view if exists mv1");
dropMvByNereids("drop materialized view if exists mv2");
}

@Test
void testWhenNotPartitionPrune() throws Exception {
connectContext.getSessionVariable().setDisableNereidsRules("PRUNE_EMPTY_PARTITION");
Expand Down Expand Up @@ -165,8 +181,6 @@ public boolean canBeCandidate() {
Assertions.assertEquals(1, mvCanRewritePartitionsMap.size());
Assertions.assertTrue(mvCanRewritePartitionsMap.keySet().iterator().next().getTableName()
.equalsIgnoreCase("mv1"));

dropMvByNereids("drop materialized view mv1");
}

@Test
Expand Down Expand Up @@ -233,6 +247,13 @@ public List<Long> getSelectedPartitionIds() {
}
};

new MockUp<MTMV>() {
@Mock
public boolean canBeCandidate() {
return true;
}
};

connectContext.getSessionVariable().enableMaterializedViewRewrite = true;
connectContext.getSessionVariable().enableMaterializedViewNestRewrite = true;
createMvByNereids("create materialized view mv2 "
Expand Down Expand Up @@ -278,7 +299,5 @@ public List<Long> getSelectedPartitionIds() {
Assertions.assertEquals(1, mvCanRewritePartitionsMap.size());
Assertions.assertTrue(mvCanRewritePartitionsMap.keySet().iterator().next().getTableName()
.equalsIgnoreCase("mv2"));

dropMvByNereids("drop materialized view mv2");
}
}
Loading