kgyrtkirk commented on a change in pull request #2975:
URL: https://github.com/apache/hive/pull/2975#discussion_r793427503



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/metadata/MaterializedViewsCache.java
##########
@@ -124,30 +124,44 @@ public void remove(Table materializedViewTable) {
       // Delete only if the create time for the input materialized view table 
and the table
       // in the map match. Otherwise, keep the one in the map.
       dbMap.computeIfPresent(materializedViewTable.getTableName(), 
(mvTableName, oldMaterialization) -> {
-        if 
(HiveMaterializedViewUtils.extractTable(oldMaterialization).equals(materializedViewTable))
 {
-          List<HiveRelOptMaterialization> materializationList =
-                  
sqlToMaterializedView.get(materializedViewTable.getViewExpandedText());
-          materializationList.remove(oldMaterialization);
+        Table oldTable = 
HiveMaterializedViewUtils.extractTable(oldMaterialization);
+        if (oldTable.equals(materializedViewTable)) {
+          remove(oldMaterialization, oldTable);
           return null;
         }
         return oldMaterialization;
       });
+
+      if (dbMap.isEmpty()) {
+        materializedViews.remove(materializedViewTable.getDbName());
+      }
     }
 
     LOG.debug("Materialized view {}.{} removed from registry",
             materializedViewTable.getDbName(), 
materializedViewTable.getTableName());
   }
 
+  private void remove(HiveRelOptMaterialization materialization, Table 
mvTable) {
+    List<HiveRelOptMaterialization> materializationList =
+            sqlToMaterializedView.get(mvTable.getViewExpandedText());
+    materializationList.remove(materialization);

Review comment:
       can this be null?




-- 
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]

Reply via email to