[refactor](nereids)make enable_stats session var (#25550)
this pr is used to test plan shape without column stats
This commit is contained in:
@ -24,7 +24,6 @@ import org.apache.doris.catalog.Partition;
|
||||
import org.apache.doris.catalog.PartitionType;
|
||||
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.FeNameFormat;
|
||||
@ -107,7 +106,7 @@ public class AlterColumnStatsStmt extends DdlStmt {
|
||||
|
||||
@Override
|
||||
public void analyze(Analyzer analyzer) throws UserException {
|
||||
if (!Config.enable_stats) {
|
||||
if (!ConnectContext.get().getSessionVariable().enableStats) {
|
||||
throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`"
|
||||
+ "in your FE conf file");
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import org.apache.doris.catalog.Database;
|
||||
import org.apache.doris.catalog.Env;
|
||||
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.UserException;
|
||||
@ -71,7 +70,7 @@ public class AlterTableStatsStmt extends DdlStmt {
|
||||
|
||||
@Override
|
||||
public void analyze(Analyzer analyzer) throws UserException {
|
||||
if (!Config.enable_stats) {
|
||||
if (!ConnectContext.get().getSessionVariable().enableStats) {
|
||||
throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`"
|
||||
+ "in your FE conf file");
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import org.apache.doris.catalog.View;
|
||||
import org.apache.doris.catalog.external.ExternalTable;
|
||||
import org.apache.doris.catalog.external.HMSExternalTable;
|
||||
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;
|
||||
@ -118,7 +117,7 @@ public class AnalyzeTblStmt extends AnalyzeStmt {
|
||||
@Override
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
public void analyze(Analyzer analyzer) throws UserException {
|
||||
if (!Config.enable_stats) {
|
||||
if (!ConnectContext.get().getSessionVariable().enableStats) {
|
||||
throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`"
|
||||
+ "in your FE conf file");
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ 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;
|
||||
@ -80,7 +79,7 @@ public class DropStatsStmt extends DdlStmt {
|
||||
|
||||
@Override
|
||||
public void analyze(Analyzer analyzer) throws UserException {
|
||||
if (!Config.enable_stats) {
|
||||
if (!ConnectContext.get().getSessionVariable().enableStats) {
|
||||
throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`"
|
||||
+ "in your FE conf file");
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ 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;
|
||||
@ -109,7 +108,7 @@ public class ShowAnalyzeStmt extends ShowStmt {
|
||||
|
||||
@Override
|
||||
public void analyze(Analyzer analyzer) throws UserException {
|
||||
if (!Config.enable_stats) {
|
||||
if (!ConnectContext.get().getSessionVariable().enableStats) {
|
||||
throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`"
|
||||
+ "in your FE conf file");
|
||||
}
|
||||
|
||||
@ -19,8 +19,8 @@ package org.apache.doris.analysis;
|
||||
|
||||
import org.apache.doris.catalog.Column;
|
||||
import org.apache.doris.catalog.ScalarType;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.UserException;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
import org.apache.doris.qe.ShowResultSetMetaData;
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ public class ShowAnalyzeTaskStatus extends ShowStmt {
|
||||
|
||||
@Override
|
||||
public void analyze(Analyzer analyzer) throws UserException {
|
||||
if (!Config.enable_stats) {
|
||||
if (!ConnectContext.get().getSessionVariable().enableStats) {
|
||||
throw new UserException("Analyze function is forbidden, you should add `enable_stats=true`"
|
||||
+ "in your FE conf file");
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import org.apache.doris.catalog.Env;
|
||||
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.util.DebugUtil;
|
||||
import org.apache.doris.nereids.NereidsPlanner;
|
||||
import org.apache.doris.nereids.StatementContext;
|
||||
@ -262,7 +261,8 @@ public class MinidumpUtils {
|
||||
for (Column column : columns) {
|
||||
String colName = column.getName();
|
||||
ColumnStatistic cache =
|
||||
Config.enable_stats ? getColumnStatistic(table, colName) : ColumnStatistic.UNKNOWN;
|
||||
ConnectContext.get().getSessionVariable().enableStats
|
||||
? getColumnStatistic(table, colName) : ColumnStatistic.UNKNOWN;
|
||||
if (cache.avgSizeByte <= 0) {
|
||||
cache = new ColumnStatisticBuilder(cache)
|
||||
.setAvgSizeByte(column.getType().getSlotSize())
|
||||
|
||||
@ -22,7 +22,6 @@ import org.apache.doris.catalog.Env;
|
||||
import org.apache.doris.catalog.OlapTable;
|
||||
import org.apache.doris.catalog.PartitionType;
|
||||
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.CascadesContext;
|
||||
@ -116,6 +115,7 @@ import org.apache.doris.nereids.trees.plans.physical.PhysicalUnion;
|
||||
import org.apache.doris.nereids.trees.plans.physical.PhysicalWindow;
|
||||
import org.apache.doris.nereids.trees.plans.visitor.DefaultPlanVisitor;
|
||||
import org.apache.doris.nereids.types.DataType;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
import org.apache.doris.statistics.ColumnStatistic;
|
||||
import org.apache.doris.statistics.ColumnStatisticBuilder;
|
||||
import org.apache.doris.statistics.Histogram;
|
||||
@ -631,9 +631,14 @@ 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 && FeConstants.enableInternalSchemaDb
|
||||
? shouldIgnoreThisCol
|
||||
? ColumnStatistic.UNKNOWN : getColumnStatistic(table, colName) : ColumnStatistic.UNKNOWN;
|
||||
ColumnStatistic cache;
|
||||
if (ConnectContext.get() == null || !ConnectContext.get().getSessionVariable().enableStats
|
||||
|| !FeConstants.enableInternalSchemaDb
|
||||
|| shouldIgnoreThisCol) {
|
||||
cache = ColumnStatistic.UNKNOWN;
|
||||
} else {
|
||||
cache = getColumnStatistic(table, colName);
|
||||
}
|
||||
if (cache.avgSizeByte <= 0) {
|
||||
cache = new ColumnStatisticBuilder(cache)
|
||||
.setAvgSizeByte(slotReference.getColumn().get().getType().getSlotSize())
|
||||
|
||||
@ -431,6 +431,13 @@ public class SessionVariable implements Serializable, Writable {
|
||||
SHOW_HIDDEN_COLUMNS
|
||||
);
|
||||
|
||||
public static final String ENABLE_STATS = "enable_stats";
|
||||
/**
|
||||
* If set false, user couldn't submit analyze SQL and FE won't allocate any related resources.
|
||||
*/
|
||||
@VariableMgr.VarAttr(name = ENABLE_STATS)
|
||||
public boolean enableStats = true;
|
||||
|
||||
// session origin value
|
||||
public Map<Field, String> sessionOriginValue = new HashMap<Field, String>();
|
||||
// check stmt is or not [select /*+ SET_VAR(...)*/ ...]
|
||||
|
||||
Reference in New Issue
Block a user