Skip to content

Commit

Permalink
fix ut test
Browse files Browse the repository at this point in the history
  • Loading branch information
seawinde committed Jun 7, 2024
1 parent e5b0840 commit 28fa036
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3885,6 +3885,10 @@ public boolean isEnableMaterializedViewRewrite() {
return enableMaterializedViewRewrite;
}

public void setEnableMaterializedViewRewrite(boolean enableMaterializedViewRewrite) {
this.enableMaterializedViewRewrite = enableMaterializedViewRewrite;
}

public boolean isMaterializedViewRewriteEnableContainExternalTable() {
return materializedViewRewriteEnableContainExternalTable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void testStarGraphWithInnerJoin() {
@Test
void testRandomQuery() {
connectContext.getSessionVariable().setDisableNereidsRules("PRUNE_EMPTY_PARTITION");
connectContext.getSessionVariable().setEnableMaterializedViewRewrite(false);
Plan p1 = new HyperGraphBuilder(Sets.newHashSet(JoinType.INNER_JOIN))
.randomBuildPlanWith(3, 3);
PlanChecker planChecker = PlanChecker.from(connectContext, p1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.doris.nereids.util.MemoTestUtils;
import org.apache.doris.nereids.util.PlanChecker;
import org.apache.doris.nereids.util.PlanConstructor;
import org.apache.doris.qe.ConnectContext;

import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -60,12 +61,14 @@ void test() {
LogicalPlan agg = new LogicalPlanBuilder(scan1)
.agg(groupBy, output)
.build();
PlanChecker.from(MemoTestUtils.createConnectContext(), agg)
ConnectContext connectContext = MemoTestUtils.createConnectContext();
connectContext.getSessionVariable().setEnableMaterializedViewRewrite(false);
PlanChecker.from(connectContext, agg)
.applyTopDown(new SimplifyAggGroupBy())
.matchesFromRoot(
logicalAggregate().when(a -> a.getGroupByExpressions().size() == 1)
);
PlanChecker.from(MemoTestUtils.createConnectContext(), agg)
PlanChecker.from(connectContext, agg)
.analyze()
.matchesFromRoot(
logicalProject(logicalAggregate().when(a -> a.getGroupByExpressions().size() == 1))
Expand All @@ -87,12 +90,14 @@ void testSqrt() {
LogicalPlan agg = new LogicalPlanBuilder(scan1)
.agg(groupBy, output)
.build();
PlanChecker.from(MemoTestUtils.createConnectContext(), agg)
ConnectContext connectContext = MemoTestUtils.createConnectContext();
connectContext.getSessionVariable().setEnableMaterializedViewRewrite(false);
PlanChecker.from(connectContext, agg)
.applyTopDown(new SimplifyAggGroupBy())
.matchesFromRoot(
logicalAggregate().when(a -> a.equals(agg))
);
PlanChecker.from(MemoTestUtils.createConnectContext(), agg)
PlanChecker.from(connectContext, agg)
.analyze()
.matchesFromRoot(
logicalProject(logicalAggregate().when(a -> a.getGroupByExpressions().size() == 2))
Expand All @@ -114,12 +119,14 @@ void testAbs() {
LogicalPlan agg = new LogicalPlanBuilder(scan1)
.agg(groupBy, output)
.build();
PlanChecker.from(MemoTestUtils.createConnectContext(), agg)
ConnectContext connectContext = MemoTestUtils.createConnectContext();
connectContext.getSessionVariable().setEnableMaterializedViewRewrite(false);
PlanChecker.from(connectContext, agg)
.applyTopDown(new SimplifyAggGroupBy())
.matchesFromRoot(
logicalAggregate().when(a -> a.equals(agg))
);
PlanChecker.from(MemoTestUtils.createConnectContext(), agg)
PlanChecker.from(connectContext, agg)
.analyze()
.matchesFromRoot(
logicalProject(logicalAggregate().when(a -> a.getGroupByExpressions().size() == 2))
Expand Down

0 comments on commit 28fa036

Please sign in to comment.