justinmclean opened a new issue, #10274:
URL: https://github.com/apache/gravitino/issues/10274

   ### What would you like to be improved?
   
   TableOperationDispatcher.purgeTable for unmanaged tables returns false when 
store.delete(ident, TABLE) throws NoSuchEntityException, even if the catalog 
purge succeeded. This contradicts the method’s own comment that store deletion 
outcome should not affect the returned result, and only the catalog result 
should be used. As a result, callers can receive false negatives 
(DropResponse(false)) for successful catalog purges.
   
   ### How should we improve?
   
   Align purgeTable with dropTable behavior: in the unmanaged branch, catch 
NoSuchEntityException, log a warning, and continue returning droppedFromCatalog 
instead of returning false. Keep throwing on other unexpected exceptions.
   
   Here a test to help:
   ```
   
   @Test
   public void 
testPurgeUnmanagedTableWithMissingStoreEntityShouldUseCatalogResult()
       throws IOException {
     CatalogManager mockedCatalogManager = mock(CatalogManager.class);
     EntityStore mockedStore = mock(EntityStore.class);
     IdGenerator mockedIdGenerator = mock(IdGenerator.class);
     CatalogManager.CatalogWrapper mockedCatalogWrapper = 
mock(CatalogManager.CatalogWrapper.class);
     org.apache.gravitino.connector.capability.Capability mockedCapability =
         mock(org.apache.gravitino.connector.capability.Capability.class);
     TableOperationDispatcher dispatcherUnderTest =
         new TableOperationDispatcher(mockedCatalogManager, mockedStore, 
mockedIdGenerator);
   
     NameIdentifier tableIdent = NameIdentifier.of(metalake, catalog, 
"schema72", "table32");
     NameIdentifier catalogIdent = NameIdentifier.of(metalake, catalog);
     
doReturn(mockedCatalogWrapper).when(mockedCatalogManager).loadCatalogAndWrap(catalogIdent);
     doReturn(mockedCapability).when(mockedCatalogWrapper).capabilities();
     doReturn(CapabilityResult.unsupported("unmanaged table"))
         .when(mockedCapability)
         
.managedStorage(org.apache.gravitino.connector.capability.Capability.Scope.TABLE);
     doReturn(true).when(mockedCatalogWrapper).doWithTableOps(any());
     doThrow(new NoSuchEntityException("missing store entity"))
         .when(mockedStore)
         .delete(tableIdent, TABLE);
   
     Assertions.assertTrue(dispatcherUnderTest.purgeTable(tableIdent));
   }
   ```


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

Reply via email to