diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java index bded743..6d81adc 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java @@ -808,7 +808,7 @@ private void updateTableColStats(RawStore rawStore, String catName, String dbNam rawStore.openTransaction(); try { Table table = rawStore.getTable(catName, dbName, tblName); - if (!table.isSetPartitionKeys()) { + if (table != null && !table.isSetPartitionKeys()) { List colNames = MetaStoreUtils.getColumnNamesForTable(table); Deadline.startTimer("getTableColumnStatistics"); @@ -852,18 +852,20 @@ private void updateTablePartitionColStats(RawStore rawStore, String catName, Str rawStore.openTransaction(); try { Table table = rawStore.getTable(catName, dbName, tblName); - List colNames = MetaStoreUtils.getColumnNamesForTable(table); - List partNames = rawStore.listPartitionNames(catName, dbName, tblName, (short) -1); - // Get partition column stats for this table - Deadline.startTimer("getPartitionColumnStatistics"); - List partitionColStats = - rawStore.getPartitionColumnStatistics(catName, dbName, tblName, partNames, colNames); - Deadline.stopTimer(); - sharedCache.refreshPartitionColStatsInCache(catName, dbName, tblName, partitionColStats); - List parts = rawStore.getPartitionsByNames(catName, dbName, tblName, partNames); - // Also save partitions for consistency as they have the stats state. - for (Partition part : parts) { - sharedCache.alterPartitionInCache(catName, dbName, tblName, part.getValues(), part); + if (table != null) { + List colNames = MetaStoreUtils.getColumnNamesForTable(table); + List partNames = rawStore.listPartitionNames(catName, dbName, tblName, (short) -1); + // Get partition column stats for this table + Deadline.startTimer("getPartitionColumnStatistics"); + List partitionColStats = + rawStore.getPartitionColumnStatistics(catName, dbName, tblName, partNames, colNames); + Deadline.stopTimer(); + sharedCache.refreshPartitionColStatsInCache(catName, dbName, tblName, partitionColStats); + List parts = rawStore.getPartitionsByNames(catName, dbName, tblName, partNames); + // Also save partitions for consistency as they have the stats state. + for (Partition part : parts) { + sharedCache.alterPartitionInCache(catName, dbName, tblName, part.getValues(), part); + } } committed = rawStore.commitTransaction(); } catch (MetaException | NoSuchObjectException e) { @@ -882,6 +884,9 @@ private static void updateTableAggregatePartitionColStats(RawStore rawStore, Str String tblName) { try { Table table = rawStore.getTable(catName, dbName, tblName); + if (table == null) { + return; + } List partNames = rawStore.listPartitionNames(catName, dbName, tblName, (short) -1); List colNames = MetaStoreUtils.getColumnNamesForTable(table); if ((partNames != null) && (partNames.size() > 0)) {