[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
This commit is contained in:
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user