Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
morningman committed Apr 21, 2024
1 parent 7d24e36 commit 60a0b3c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public void setName(String newName) {
name = newName;
}

void setQualifiedDbName(String qualifiedDbName) {
public void setQualifiedDbName(String qualifiedDbName) {
this.qualifiedDbName = qualifiedDbName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void randomTest(int tableNum, int edgeNum) {
plan = new LogicalProject(plan.getOutput(), plan);
Set<List<String>> res1 = hyperGraphBuilder.evaluate(plan);
CascadesContext cascadesContext = MemoTestUtils.createCascadesContext(connectContext, plan);
hyperGraphBuilder.initStats(cascadesContext);
hyperGraphBuilder.initStats("tpch", cascadesContext);
Plan optimizedPlan = PlanChecker.from(cascadesContext)
.dpHypOptimize()
.getBestPlanTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void randomTest(int tableNum, int edgeNum, boolean withJoinHint, boolean
Set<List<String>> res1 = hyperGraphBuilder.evaluate(plan);
if (!withLeading) {
CascadesContext cascadesContext = MemoTestUtils.createCascadesContext(connectContext, plan);
hyperGraphBuilder.initStats(cascadesContext);
hyperGraphBuilder.initStats("tpch", cascadesContext);
Plan optimizedPlan = PlanChecker.from(cascadesContext)
.analyze()
.optimize()
Expand All @@ -128,7 +128,7 @@ private void randomTest(int tableNum, int edgeNum, boolean withJoinHint, boolean
for (int i = 0; i < (tableNum * tableNum - 1); i++) {
Plan leadingPlan = generateLeadingHintPlan(tableNum, plan);
CascadesContext cascadesContext = MemoTestUtils.createCascadesContext(connectContext, leadingPlan);
hyperGraphBuilder.initStats(cascadesContext);
hyperGraphBuilder.initStats("tpch", cascadesContext);
Plan optimizedPlan = PlanChecker.from(cascadesContext)
.analyze()
.optimize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import java.util.Set;

class RankTest extends TestWithFeService {

@Test
void test() {
void test() throws Exception {
createDatabase("test");
HyperGraphBuilder hyperGraphBuilder = new HyperGraphBuilder(Sets.newHashSet(JoinType.INNER_JOIN));
hyperGraphBuilder.init(0, 1, 2);
Plan plan = hyperGraphBuilder
Expand All @@ -45,7 +47,7 @@ void test() {
.buildPlan();
plan = new LogicalProject(plan.getOutput(), plan);
CascadesContext cascadesContext = MemoTestUtils.createCascadesContext(connectContext, plan);
hyperGraphBuilder.initStats(cascadesContext);
hyperGraphBuilder.initStats("test", cascadesContext);
PhysicalPlan bestPlan = PlanChecker.from(cascadesContext)
.optimize()
.getBestPlanTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected void test64TableJoin() {
plan = new LogicalProject(plan.getOutput(), plan);
CascadesContext cascadesContext = MemoTestUtils.createCascadesContext(connectContext, plan);
Assertions.assertEquals(cascadesContext.getMemo().countMaxContinuousJoin(), 64);
hyperGraphBuilder.initStats(cascadesContext);
hyperGraphBuilder.initStats("test", cascadesContext);
PlanChecker.from(cascadesContext)
.optimize()
.getBestPlanTree();
Expand All @@ -153,7 +153,7 @@ void test64CliqueJoin() {
.randomBuildPlanWith(64, 64 * 63 / 2);
plan = new LogicalProject(plan.getOutput(), plan);
CascadesContext cascadesContext = MemoTestUtils.createCascadesContext(connectContext, plan);
hyperGraphBuilder.initStats(cascadesContext);
hyperGraphBuilder.initStats("test", cascadesContext);
PlanChecker.from(cascadesContext)
.rewrite()
.dpHypOptimize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.doris.statistics.StatisticsCacheKey;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

Expand Down Expand Up @@ -195,12 +196,15 @@ public HyperGraphBuilder init(int... rowCounts) {
return this;
}

public void initStats(CascadesContext context) {
public void initStats(String dbName, CascadesContext context) {
for (Group group : context.getMemo().getGroups()) {
GroupExpression groupExpression = group.getLogicalExpression();
if (groupExpression.getPlan() instanceof LogicalOlapScan) {
LogicalOlapScan scan = (LogicalOlapScan) groupExpression.getPlan();
OlapTable table = scan.getTable();
if (Strings.isNullOrEmpty(table.getQualifiedDbName())) {
table.setQualifiedDbName(dbName);
}
Statistics stats = injectRowcount((LogicalOlapScan) groupExpression.getPlan());
for (Expression expr : stats.columnStatistics().keySet()) {
SlotReference slot = (SlotReference) expr;
Expand Down

0 comments on commit 60a0b3c

Please sign in to comment.