Make sure external table fetched dbId before call getRowCount. (#31379)

This commit is contained in:
Jibing-Li
2024-02-27 16:41:56 +08:00
committed by yiguolei
parent 41e31ee333
commit 37590f1778

View File

@ -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);
}