Kikyou1997 commented on code in PR #18971:
URL: https://github.com/apache/doris/pull/18971#discussion_r1176146017
##########
fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java:
##########
@@ -109,6 +122,80 @@ public void createAnalysisJob(AnalyzeStmt stmt) throws
DdlException {
analysisTaskInfos.values().forEach(taskScheduler::schedule);
}
+ /**
+ * Gets the partitions for which statistics are to be collected. First
verify that
+ * there are partitions that have been deleted but have historical
statistics(invalid statistics),
+ * if there are these partitions, we need to delete them to avoid errors
in summary table level statistics.
+ * Then get the partitions for which statistics need to be collected based
on collection mode (incremental/full).
+ * <p>
+ * note:
+ * If there is no invalid statistics, it does not need to collect/update
+ * statistics if the following conditions are met:
+ * - in full collection mode, the partitioned table does not have
partitions
+ * - in incremental collection mode, partition statistics already exist
+ * <p>
+ * TODO Supports incremental collection of statistics from materialized
views
+ */
+ private Map<String, Set<String>> validateAndGetPartitions(AnalyzeStmt
stmt) throws DdlException {
+ TableIf table = stmt.getTable();
+ long tableId = table.getId();
+ Set<String> columnNames = stmt.getColumnNames();
+ Set<String> partitionNames = table.getPartitionNames();
+
+ Map<String, Set<String>> columnToPartitions = Maps.newHashMap();
+ columnNames.forEach(column -> columnToPartitions
+ .computeIfAbsent(column, partitions -> new
HashSet<>()).addAll(partitionNames));
Review Comment:
Seems `computeIfAbsent` here is redundant, since `columnToPartitions` is
always empty when invoke `columnToPartitions`, thought the overhead is not too
much
--
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]