This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 08662829bfe6fce6e38502d87f1f31770345bf2f Author: 谢健 <jianx...@gmail.com> AuthorDate: Fri Jul 21 11:30:26 2023 +0800 [fix](test) should not create and read internal table when use mock cluster in UT (#21660) --- .../java/org/apache/doris/catalog/InternalSchemaInitializer.java | 2 +- .../src/main/java/org/apache/doris/common/FeConstants.java | 4 ++-- .../java/org/apache/doris/nereids/stats/StatsCalculator.java | 4 +++- .../org/apache/doris/nereids/datasets/tpch/TPCHTestBase.java | 9 --------- .../test/java/org/apache/doris/utframe/TestWithFeService.java | 2 +- .../src/test/java/org/apache/doris/utframe/UtFrameUtils.java | 4 ++-- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchemaInitializer.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchemaInitializer.java index 5b3a093f77..e17329bc0f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchemaInitializer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchemaInitializer.java @@ -55,7 +55,7 @@ public class InternalSchemaInitializer extends Thread { private static final Logger LOG = LogManager.getLogger(InternalSchemaInitializer.class); public void run() { - if (FeConstants.disableInternalSchemaDb) { + if (!FeConstants.enableInternalSchemaDb) { return; } while (!created()) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java b/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java index d266d35c61..28241da750 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java @@ -50,8 +50,8 @@ public class FeConstants { // set to true to skip some step when running FE unit test public static boolean runningUnitTest = false; - // set to true to disable internal schema db - public static boolean disableInternalSchemaDb = false; + // set to false to disable internal schema db + public static boolean enableInternalSchemaDb = true; // default scheduler interval is 10 seconds public static int default_scheduler_interval_millisecond = 10000; 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 3b58c04eb8..ca42df4e30 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 @@ -23,6 +23,7 @@ import org.apache.doris.catalog.OlapTable; import org.apache.doris.catalog.SchemaTable; import org.apache.doris.catalog.TableIf; import org.apache.doris.common.Config; +import org.apache.doris.common.FeConstants; import org.apache.doris.common.Pair; import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.memo.Group; @@ -591,7 +592,8 @@ public class StatsCalculator extends DefaultPlanVisitor<Statistics, Void> { if (colName == null) { throw new RuntimeException(String.format("Invalid slot: %s", slotReference.getExprId())); } - ColumnStatistic cache = Config.enable_stats ? getColumnStatistic(table, colName) : ColumnStatistic.UNKNOWN; + ColumnStatistic cache = Config.enable_stats && FeConstants.enableInternalSchemaDb + ? getColumnStatistic(table, colName) : ColumnStatistic.UNKNOWN; if (cache.avgSizeByte <= 0) { cache = new ColumnStatisticBuilder(cache) .setAvgSizeByte(slotReference.getColumn().get().getType().getSlotSize()) diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/datasets/tpch/TPCHTestBase.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/datasets/tpch/TPCHTestBase.java index a0c9b77f7e..71dddf165c 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/datasets/tpch/TPCHTestBase.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/datasets/tpch/TPCHTestBase.java @@ -17,18 +17,9 @@ package org.apache.doris.nereids.datasets.tpch; -import org.apache.doris.catalog.InternalSchemaInitializer; -import org.apache.doris.common.FeConstants; - public abstract class TPCHTestBase extends AnalyzeCheckTestBase { @Override protected void runBeforeAll() throws Exception { - // The internal table for TPCHTestBase is constructed in order to facilitate - // the execution of certain tests that require the invocation of a deriveStats job. - // This deriveStats job is responsible for retrieving statistics from the aforementioned - // internal table. - FeConstants.disableInternalSchemaDb = false; - new InternalSchemaInitializer().run(); createDatabase("tpch"); connectContext.setDatabase("default_cluster:tpch"); TPCHUtils.createTables(this); diff --git a/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java b/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java index f2610738f3..cec9586e96 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java +++ b/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java @@ -125,7 +125,7 @@ public abstract class TestWithFeService { @BeforeAll public final void beforeAll() throws Exception { - FeConstants.disableInternalSchemaDb = true; + FeConstants.enableInternalSchemaDb = false; beforeCreatingConnectContext(); connectContext = createDefaultCtx(); beforeCluster(); diff --git a/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java b/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java index 38c883c93c..4213b7136f 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java +++ b/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java @@ -210,7 +210,7 @@ public class UtFrameUtils { public static void createDorisCluster(String runningDir, int backendNum) throws EnvVarNotSetException, IOException, FeStartException, NotInitException, DdlException, InterruptedException { - FeConstants.disableInternalSchemaDb = true; + FeConstants.enableInternalSchemaDb = false; int feRpcPort = startFEServer(runningDir); List<Backend> bes = Lists.newArrayList(); for (int i = 0; i < backendNum; i++) { @@ -245,7 +245,7 @@ public class UtFrameUtils { // set runningUnitTest to true, so that for ut, // the agent task will be sent to "127.0.0.1" to make cluster running well. FeConstants.runningUnitTest = true; - FeConstants.disableInternalSchemaDb = true; + FeConstants.enableInternalSchemaDb = false; int feRpcPort = startFEServer(runningDir); for (int i = 0; i < backendNum; i++) { String host = "127.0.0." + (i + 1); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org