weizhengte commented on code in PR #8860: URL: https://github.com/apache/incubator-doris/pull/8860#discussion_r855727868
########## fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsManager.java: ########## @@ -128,12 +135,47 @@ private List<String> showTableStats(Table table) throws AnalysisException { return row; } + public void alterTableStatistics(StatisticsTaskResult taskResult) throws AnalysisException { + StatsCategoryDesc categoryDesc = taskResult.getCategoryDesc(); + validateTableAndColumn(categoryDesc); + long tblId = categoryDesc.getTableId(); + Map<String, String> statsNameToValue = taskResult.getStatsNameToValue(); + this.statistics.updateTableStats(tblId, statsNameToValue); + } + + public void alterColumnStatistics(StatisticsTaskResult taskResult) throws AnalysisException { + StatsCategoryDesc categoryDesc = taskResult.getCategoryDesc(); + validateTableAndColumn(categoryDesc); + long dbId = categoryDesc.getDbId(); + long tblId = categoryDesc.getTableId(); + Database db = Catalog.getCurrentCatalog().getDbOrAnalysisException(dbId); + Table table = db.getTableOrAnalysisException(tblId); + String columnName = categoryDesc.getColumnName(); + Type columnType = table.getColumn(columnName).getType(); + Map<String, String> statsNameToValue = taskResult.getStatsNameToValue(); + this.statistics.updateColumnStats(tblId, columnName, columnType, statsNameToValue); + } + private Table validateTableName(TableName dbTableName) throws AnalysisException { String dbName = dbTableName.getDb(); String tableName = dbTableName.getTbl(); Database db = Catalog.getCurrentCatalog().getDbOrAnalysisException(dbName); - Table table = db.getTableOrAnalysisException(tableName); - return table; + return db.getTableOrAnalysisException(tableName); + } + + private void validateTableAndColumn(StatsCategoryDesc categoryDesc) throws AnalysisException { + long dbId = categoryDesc.getDbId(); + long tblId = categoryDesc.getTableId(); + String columnName = categoryDesc.getColumnName(); + + Database db = Catalog.getCurrentCatalog().getDbOrAnalysisException(dbId); + Table table = db.getTableOrAnalysisException(tblId); + if (!Strings.isNullOrEmpty(columnName)) { + Column column = table.getColumn(columnName); + if (column == null) { Review Comment: yes, this will be caught in the method that calls it, and the log will be printed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org