diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalTable.java index ce3220a05f..a84f637cd2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalTable.java @@ -297,6 +297,14 @@ public class ExternalTable implements TableIf, Writable, GsonPostProcessable { @Override public long getRowCount() { + // Return 0 if makeSureInitialized throw exception. + // For example, init hive table may throw NotSupportedException. + try { + makeSureInitialized(); + } catch (Exception e) { + LOG.warn("Failed to initialize table {}.{}.{}", catalog.name, dbName, name, e); + return 0; + } // All external table should get external row count from cache. return Env.getCurrentEnv().getExtMetaCacheMgr().getRowCountCache().getCachedRowCount(catalog.getId(), dbId, id); }