Skip to content

Commit 40f886f

Browse files
committed
update
1 parent d1d0d1c commit 40f886f

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import org.apache.doris.common.DdlException;
2626
import org.apache.doris.common.Pair;
2727
import org.apache.doris.common.util.MasterDaemon;
28-
import org.apache.doris.datasource.ExternalTable;
29-
import org.apache.doris.datasource.hive.HMSExternalTable;
3028
import org.apache.doris.datasource.iceberg.IcebergExternalTable;
3129
import org.apache.doris.info.TableNameInfo;
3230
import org.apache.doris.persist.TableStatsDeletionLog;
@@ -150,7 +148,7 @@ protected void processOneJob(TableIf table, Set<Pair<String, String>> columns, J
150148
if (StatisticsUtil.enablePartitionAnalyze() && table.isPartitionedTable()) {
151149
analysisMethod = AnalysisMethod.FULL;
152150
}
153-
if (table instanceof ExternalTable) { // External table only support full analyze now
151+
if (table instanceof IcebergExternalTable) { // IcebergExternalTable table only support full analyze now
154152
analysisMethod = AnalysisMethod.FULL;
155153
}
156154
boolean isSampleAnalyze = analysisMethod.equals(AnalysisMethod.SAMPLE);
@@ -234,9 +232,7 @@ protected boolean supportAutoAnalyze(TableIf tableIf) {
234232
if (tableIf == null) {
235233
return false;
236234
}
237-
return tableIf instanceof OlapTable || tableIf instanceof IcebergExternalTable
238-
|| tableIf instanceof HMSExternalTable
239-
&& ((HMSExternalTable) tableIf).getDlaType().equals(HMSExternalTable.DLAType.HIVE);
235+
return StatisticsUtil.supportAutoAnalyze(tableIf);
240236
}
241237

242238
protected AnalysisInfo createAnalyzeJobForTbl(TableIf table, Set<Pair<String, String>> jobColumns,

fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,22 +1131,45 @@ public static boolean needAnalyzeColumn(TableIf table, Pair<String, String> colu
11311131
// 3. Check partition
11321132
return needAnalyzePartition(olapTable, tableStatsStatus, columnStatsMeta);
11331133
} else {
1134-
if (!(table instanceof HMSExternalTable || (table instanceof IcebergExternalTable))) {
1134+
if (!StatisticsUtil.supportAutoAnalyze(table)) {
11351135
return false;
11361136
}
1137-
if (table instanceof HMSExternalTable) {
1138-
HMSExternalTable hmsTable = (HMSExternalTable) table;
1139-
if (!hmsTable.getDlaType().equals(DLAType.HIVE) && !hmsTable.getDlaType().equals(DLAType.ICEBERG)) {
1140-
return false;
1141-
}
1142-
}
11431137
// External is hard to calculate change rate, use time interval to control
11441138
// analyze frequency.
11451139
return System.currentTimeMillis()
11461140
- tableStatsStatus.lastAnalyzeTime > StatisticsUtil.getExternalTableAutoAnalyzeIntervalInMillis();
11471141
}
11481142
}
11491143

1144+
/**
1145+
* Check if the table supports auto analyze feature.
1146+
* @param table The table to check
1147+
* @return true if the table supports auto analyze, false otherwise
1148+
*/
1149+
public static boolean supportAutoAnalyze(TableIf table) {
1150+
if (table == null) {
1151+
return false;
1152+
}
1153+
1154+
// Support OLAP table
1155+
if (table instanceof OlapTable) {
1156+
return true;
1157+
}
1158+
1159+
// Support Iceberg table
1160+
if (table instanceof IcebergExternalTable) {
1161+
return true;
1162+
}
1163+
1164+
// Support HMS table (only HIVE and ICEBERG types)
1165+
if (table instanceof HMSExternalTable) {
1166+
HMSExternalTable hmsTable = (HMSExternalTable) table;
1167+
DLAType dlaType = hmsTable.getDlaType();
1168+
return dlaType.equals(DLAType.HIVE) || dlaType.equals(DLAType.ICEBERG);
1169+
}
1170+
return false;
1171+
}
1172+
11501173
public static boolean needAnalyzePartition(OlapTable table, TableStatsMeta tableStatsStatus,
11511174
ColStatsMeta columnStatsMeta) {
11521175
if (!StatisticsUtil.enablePartitionAnalyze() || !table.isPartitionedTable()) {

0 commit comments

Comments
 (0)