This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 270be55c4c [feat](stats) Add option to config file to enable or disable analyze function (#19062) 270be55c4c is described below commit 270be55c4cb0c939fc43b9b8f3e66338d19035c7 Author: AKIRA <33112463+kikyou1...@users.noreply.github.com> AuthorDate: Wed Apr 26 14:37:08 2023 +0900 [feat](stats) Add option to config file to enable or disable analyze function (#19062) Add this option in conf: /** * If set false, user couldn't submit analyze SQL and FE won't allocate any related resources. */ @ConfField public static boolean enable_stats = true; It will be checked during analyze of analyze related stmt and init analyze manager --- fe/fe-common/src/main/java/org/apache/doris/common/Config.java | 6 ++++++ .../main/java/org/apache/doris/analysis/AlterColumnStatsStmt.java | 5 +++++ fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyzeStmt.java | 5 +++++ .../src/main/java/org/apache/doris/analysis/DropStatsStmt.java | 5 +++++ .../src/main/java/org/apache/doris/analysis/ShowAnalyzeStmt.java | 5 +++++ fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java | 2 +- .../main/java/org/apache/doris/nereids/stats/StatsCalculator.java | 6 ++++-- 7 files changed, 31 insertions(+), 3 deletions(-) diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java index f8092785d6..b4fbb28aac 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java +++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java @@ -2149,5 +2149,11 @@ public class Config extends ConfigBase { */ @ConfField(mutable = false) public static boolean skip_localhost_auth_check = false; + + /** + * If set false, user couldn't submit analyze SQL and FE won't allocate any related resources. + */ + @ConfField + public static boolean enable_stats = true; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterColumnStatsStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterColumnStatsStmt.java index 1c527bd06d..bcb1aa1596 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterColumnStatsStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterColumnStatsStmt.java @@ -22,6 +22,7 @@ import org.apache.doris.catalog.Env; import org.apache.doris.catalog.OlapTable; import org.apache.doris.catalog.Table; import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.Config; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; import org.apache.doris.common.FeNameFormat; @@ -99,6 +100,10 @@ public class AlterColumnStatsStmt extends DdlStmt { @Override public void analyze(Analyzer analyzer) throws UserException { + if (!Config.enable_stats) { + throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`" + + "in your FE conf file"); + } super.analyze(analyzer); // check table name diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyzeStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyzeStmt.java index 093dfad776..f4d9319ec7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyzeStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyzeStmt.java @@ -25,6 +25,7 @@ import org.apache.doris.catalog.OlapTable; import org.apache.doris.catalog.TableIf; import org.apache.doris.catalog.View; import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.Config; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; import org.apache.doris.common.FeNameFormat; @@ -112,6 +113,10 @@ public class AnalyzeStmt extends DdlStmt { @Override public void analyze(Analyzer analyzer) throws UserException { + if (!Config.enable_stats) { + throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`" + + "in your FE conf file"); + } super.analyze(analyzer); tableName.analyze(analyzer); diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropStatsStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropStatsStmt.java index 137db5e310..df50f45bb3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropStatsStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropStatsStmt.java @@ -22,6 +22,7 @@ import org.apache.doris.catalog.DatabaseIf; import org.apache.doris.catalog.Env; import org.apache.doris.catalog.TableIf; import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.Config; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; import org.apache.doris.common.UserException; @@ -69,6 +70,10 @@ public class DropStatsStmt extends DdlStmt { @Override public void analyze(Analyzer analyzer) throws UserException { + if (!Config.enable_stats) { + throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`" + + "in your FE conf file"); + } super.analyze(analyzer); if (dropExpired) { return; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowAnalyzeStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowAnalyzeStmt.java index b0493cce72..b91e171a03 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowAnalyzeStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowAnalyzeStmt.java @@ -21,6 +21,7 @@ import org.apache.doris.catalog.Column; import org.apache.doris.catalog.Env; import org.apache.doris.catalog.ScalarType; import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.Config; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; import org.apache.doris.common.UserException; @@ -184,6 +185,10 @@ public class ShowAnalyzeStmt extends ShowStmt { @Override public void analyze(Analyzer analyzer) throws UserException { + if (!Config.enable_stats) { + throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`" + + "in your FE conf file"); + } super.analyze(analyzer); catalogName = analyzer.getEnv().getInternalCatalog().getName(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index 1c02e30e19..dff19b31af 100755 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -650,7 +650,7 @@ public class Env { this.mtmvJobManager = new MTMVJobManager(); this.extMetaCacheMgr = new ExternalMetaCacheMgr(); this.fqdnManager = new FQDNManager(systemInfo); - if (!isCheckpointCatalog) { + if (Config.enable_stats && !isCheckpointCatalog) { this.analysisManager = new AnalysisManager(); this.statisticsCleaner = new StatisticsCleaner(); } 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 f87c7bf3a1..b47452fa65 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 @@ -19,6 +19,7 @@ package org.apache.doris.nereids.stats; import org.apache.doris.catalog.Env; import org.apache.doris.catalog.TableIf; +import org.apache.doris.common.Config; import org.apache.doris.common.Pair; import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.memo.Group; @@ -434,8 +435,9 @@ public class StatsCalculator extends DefaultPlanVisitor<Statistics, Void> { if (colName == null) { throw new RuntimeException(String.format("Invalid slot: %s", slotReference.getExprId())); } - ColumnStatistic cache = - Env.getCurrentEnv().getStatisticsCache().getColumnStatistics(table.getId(), colName); + ColumnStatistic cache = Config.enable_stats + ? Env.getCurrentEnv().getStatisticsCache().getColumnStatistics(table.getId(), colName) + : ColumnStatistic.UNKNOWN; if (cache == ColumnStatistic.UNKNOWN) { if (ConnectContext.get().getSessionVariable().forbidUnknownColStats) { throw new AnalysisException("column stats for " + colName --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org