weizhengte commented on code in PR #8862:
URL: https://github.com/apache/doris/pull/8862#discussion_r935838686
##########
fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJob.java:
##########
@@ -265,4 +273,86 @@ public static StatisticsJob fromAnalyzeStmt(AnalyzeStmt
stmt) throws AnalysisExc
Map<String, String> properties = stmt.getProperties();
return new StatisticsJob(dbId, tblIds, tableIdToPartitionName,
tableIdToColumnName, properties);
}
+
+ public List<Comparable> getShowInfo(@Nullable Long tableId) throws
AnalysisException {
+ List<Comparable> result = Lists.newArrayList();
+
+ result.add(Long.toString(id));
+
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss.SSS");
+ result.add(TimeUtils.longToTimeString(createTime, dateFormat));
+ result.add(startTime != -1L ? TimeUtils.longToTimeString(startTime,
dateFormat) : "N/A");
+ result.add(finishTime != -1L ? TimeUtils.longToTimeString(finishTime,
dateFormat) : "N/A");
+
+ StringBuilder sb = new StringBuilder();
+ for (String errorMsg : errorMsgs) {
+ sb.append(errorMsg).append("\n");
+ }
+ result.add(sb.toString());
+
+ int totalTaskNum = 0;
+ int finishedTaskNum = 0;
+ Map<Long, Set<String>> tblIdToCols = Maps.newHashMap();
+
+ for (StatisticsTask task : tasks) {
+ List<StatisticsDesc> statsDescs = task.getStatsDescs();
+
+ if (!statsDescs.isEmpty()) {
+ // The same task has the same stats properties
+ StatsCategory statsCategory =
statsDescs.get(0).getStatsCategory();
+ long tblId = statsCategory.getTableId();
+
+ if (tableId == null || tableId == tblId) {
+ totalTaskNum++;
+ if (task.getTaskState() ==
StatisticsTask.TaskState.FINISHED) {
+ finishedTaskNum++;
+ }
+
+ String col = statsCategory.getColumnName();
+ if (Strings.isNullOrEmpty(col)) {
+ continue;
+ }
+ if (tblIdToCols.containsKey(tblId)) {
+ tblIdToCols.get(tblId).add(col);
+ } else {
+ Set<String> cols = Sets.newHashSet();
+ cols.add(col);
+ tblIdToCols.put(tblId, cols);
+ }
+ }
+ }
+ }
+
+ List<String> scope = Lists.newArrayList();
+ Database db = Env.getCurrentEnv()
+ .getInternalDataSource().getDbOrAnalysisException(dbId);
+ for (Long tblId : tblIds) {
+ try {
+ Table table = db.getTableOrAnalysisException(tblId);
+ List<Column> baseSchema = table.getBaseSchema();
+ Set<String> cols = tblIdToCols.get(tblId);
+ if (cols != null) {
+ if (baseSchema.size() == cols.size()) {
+ scope.add(table.getName() + "(*)");
+ } else {
+ scope.add(table.getName() + "(" +
StringUtils.join(cols.toArray(), ",") + ")");
+ }
+ }
+ } catch (AnalysisException e) {
+ // catch this exception when table is dropped
+ LOG.info("get table failed, tableId: " + tblId, e);
+ }
+ }
+
+ result.add(StringUtils.join(scope.toArray(), ","));
+ result.add(finishedTaskNum + "/" + totalTaskNum);
+
+ if (totalTaskNum == finishedTaskNum) {
Review Comment:
a statistical job will be divided into multiple tasks to execute, so the job
status is finished means that all tasks have been finished.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]