felixschneider99 commented on issue #14743:
URL: https://github.com/apache/iceberg/issues/14743#issuecomment-3611144056

   I did some experimentation locally and built my own JARs.
   The issue comes from the hardcoded **FALSE** value in the 
**dropTableWithPurging()** method.
   
   The following code fixes the problem:
   ```
   @Override
   public boolean purgeTable(Identifier ident) {
     try {
       org.apache.iceberg.Table table = 
icebergCatalog.loadTable(buildIdentifier(ident));
       ValidationException.check(
           PropertyUtil.propertyAsBoolean(table.properties(), GC_ENABLED, 
GC_ENABLED_DEFAULT),
           "Cannot purge table: GC is disabled (deleting files may corrupt 
other tables)");
   
       String metadataFileLocation =
           ((HasTableOperations) 
table).operations().current().metadataFileLocation();
   
       boolean dropped = dropTableWithPurging(ident);
   
       if (dropped) {
         // check whether the metadata file exists because 
HadoopCatalog/HadoopTables
         // will drop the warehouse directly and ignore the `purge` argument
         boolean metadataFileExists = 
table.io().newInputFile(metadataFileLocation).exists();
   
         if (metadataFileExists) {
           
SparkActions.get().deleteReachableFiles(metadataFileLocation).io(table.io()).execute();
         }
       }
   
       return dropped;
     } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
       return false;
     }
   }
   
   private boolean dropTableWithPurging(Identifier ident) {
     if (isPathIdentifier(ident)) {
       return tables.dropTable(((PathIdentifier) ident).location(), true /* 
purge data */);
     } else {
       return icebergCatalog.dropTable(buildIdentifier(ident), true /* purge 
data */);
     }
   }
   ```
   
   Why was this implemented this way? Is there a specific reason why the 
**purgedata()** path triggers **dropTableWithoutPurging()** internally?
   
   It seems like a bug, because the purge argument is effectively ignored.
   


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