From d09933292b8dea999016aaa4aa9aed2985d39a92 Mon Sep 17 00:00:00 2001 From: minghong Date: Mon, 21 Oct 2024 16:22:58 +0800 Subject: [PATCH] fix ut --- .../java/org/apache/doris/nereids/stats/StatsCalculator.java | 5 +++++ .../doris/nereids/jobs/cascades/DeriveStatsJobTest.java | 2 ++ .../test/java/org/apache/doris/nereids/memo/RankTest.java | 2 ++ .../test/java/org/apache/doris/planner/ColocatePlanTest.java | 1 + 4 files changed, 10 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java index eda4e1359de9a55..af99e24b9a8e395 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java @@ -860,6 +860,11 @@ private Statistics computeCatalogRelation(CatalogRelation catalogRelation) { // rows newly updated after last analyze long deltaRowCount = computeDeltaRowCount(catalogRelation); double rowCount = getTableRowCount(catalogRelation); + if (FeConstants.runningUnitTest || !FeConstants.enableInternalSchemaDb) { + rowCount = Math.max(1, rowCount); + } else { + rowCount = Math.max(0, rowCount); + } boolean hasUnknownCol = false; long idxId = -1; if (catalogRelation instanceof OlapScan) { diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java index 0f73b38ac8d3c49..7822f5f004b05ab 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java @@ -20,6 +20,7 @@ import org.apache.doris.catalog.Column; import org.apache.doris.catalog.OlapTable; import org.apache.doris.catalog.PrimitiveType; +import org.apache.doris.common.FeConstants; import org.apache.doris.mysql.privilege.MockedAuth; import org.apache.doris.nereids.CascadesContext; import org.apache.doris.nereids.jobs.JobContext; @@ -62,6 +63,7 @@ public class DeriveStatsJobTest { @Test public void testExecute() throws Exception { + FeConstants.runningUnitTest = true; MockedAuth.mockedConnectContext(context, "root", "192.168.1.1"); LogicalOlapScan olapScan = constructOlapSCan(); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/memo/RankTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/memo/RankTest.java index 7d3cc0103b3742c..e05c2ea28d8b300 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/memo/RankTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/memo/RankTest.java @@ -17,6 +17,7 @@ package org.apache.doris.nereids.memo; +import org.apache.doris.common.FeConstants; import org.apache.doris.nereids.CascadesContext; import org.apache.doris.nereids.trees.plans.JoinType; import org.apache.doris.nereids.trees.plans.Plan; @@ -38,6 +39,7 @@ class RankTest extends TestWithFeService { @Test void test() throws Exception { + FeConstants.runningUnitTest = true; createDatabase("test"); HyperGraphBuilder hyperGraphBuilder = new HyperGraphBuilder(Sets.newHashSet(JoinType.INNER_JOIN)); hyperGraphBuilder.init(0, 1, 2); diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/ColocatePlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/ColocatePlanTest.java index d334b5eeb4e3aee..afd607bbb3af24d 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/ColocatePlanTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/ColocatePlanTest.java @@ -210,6 +210,7 @@ public void testGlobalColocateGroup() throws Exception { + "db1.test_global_colocate1 group by k1, k2) a , db2.test_global_colocate2 b " + "where a.k1=b.k1 and a.k2=b.k2"; String plan1 = getSQLPlanOrErrorMsg(sql); + System.out.println(plan1); Assert.assertEquals(1, StringUtils.countMatches(plan1, "AGGREGATE")); Assert.assertTrue(plan1.contains(COLOCATE_ENABLE)); ColocateTableIndex colocateTableIndex = Env.getCurrentColocateIndex();