[Fix](statistics)Fix external couldn't analyze database bug (#26025)

This commit is contained in:
Jibing-Li
2023-10-31 11:32:47 +08:00
committed by GitHub
parent 3184060fa7
commit 78204f7c92
6 changed files with 103 additions and 8 deletions

View File

@ -105,13 +105,17 @@ public class AnalyzeTblStmt extends AnalyzeStmt {
}
public AnalyzeTblStmt(AnalyzeProperties analyzeProperties, TableName tableName, List<String> columnNames, long dbId,
TableIf table) {
TableIf table) throws AnalysisException {
super(analyzeProperties);
this.tableName = tableName;
this.columnNames = columnNames;
this.dbId = dbId;
this.table = table;
this.isAllColumns = columnNames == null;
String catalogName = tableName.getCtl();
CatalogIf catalog = Env.getCurrentEnv().getCatalogMgr()
.getCatalogOrAnalysisException(catalogName);
this.catalogId = catalog.getId();
}
@Override

View File

@ -2059,7 +2059,7 @@ public class StmtExecutor {
context.getState().setOk();
}
private void handleAnalyzeStmt() throws DdlException {
private void handleAnalyzeStmt() throws DdlException, AnalysisException {
context.env.getAnalysisManager().createAnalyze((AnalyzeStmt) parsedStmt, isProxy);
}

View File

@ -287,7 +287,7 @@ public class AnalysisManager extends Daemon implements Writable {
return statisticsCache;
}
public void createAnalyze(AnalyzeStmt analyzeStmt, boolean proxy) throws DdlException {
public void createAnalyze(AnalyzeStmt analyzeStmt, boolean proxy) throws DdlException, AnalysisException {
if (!StatisticsUtil.statsTblAvailable() && !FeConstants.runningUnitTest) {
throw new DdlException("Stats table not available, please make sure your cluster status is normal");
}
@ -298,7 +298,7 @@ public class AnalysisManager extends Daemon implements Writable {
}
}
public void createAnalysisJobs(AnalyzeDBStmt analyzeDBStmt, boolean proxy) throws DdlException {
public void createAnalysisJobs(AnalyzeDBStmt analyzeDBStmt, boolean proxy) throws DdlException, AnalysisException {
DatabaseIf<TableIf> db = analyzeDBStmt.getDb();
// Using auto analyzer if user specifies.
if (analyzeDBStmt.getAnalyzeProperties().getProperties().containsKey("use.auto.analyzer")) {
@ -311,7 +311,8 @@ public class AnalysisManager extends Daemon implements Writable {
}
}
public List<AnalysisInfo> buildAnalysisInfosForDB(DatabaseIf<TableIf> db, AnalyzeProperties analyzeProperties) {
public List<AnalysisInfo> buildAnalysisInfosForDB(DatabaseIf<TableIf> db, AnalyzeProperties analyzeProperties)
throws AnalysisException {
db.readLock();
List<TableIf> tbls = db.getTables();
List<AnalysisInfo> analysisInfos = new ArrayList<>();