Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ public class ThriftHiveMetastore

private static final String DEFAULT_METASTORE_USER = "presto";

private final HdfsContext hdfsContext = new HdfsContext(ConnectorIdentity.ofUser(DEFAULT_METASTORE_USER));

private final Optional<ConnectorIdentity> identity;
private final HdfsEnvironment hdfsEnvironment;
private final IdentityAwareMetastoreClientFactory metastoreClientFactory;
Expand Down Expand Up @@ -955,7 +953,7 @@ public void dropTable(String databaseName, String tableName, boolean deleteData)
client.dropTable(databaseName, tableName, deleteData);
String tableLocation = table.getSd().getLocation();
if (deleteFilesOnDrop && deleteData && isManagedTable(table) && !isNullOrEmpty(tableLocation)) {
deleteDirRecursive(hdfsContext, hdfsEnvironment, new Path(tableLocation));
deleteDirRecursive(new Path(tableLocation));
}
}
return null;
Expand All @@ -972,9 +970,11 @@ public void dropTable(String databaseName, String tableName, boolean deleteData)
}
}

private static void deleteDirRecursive(HdfsContext context, HdfsEnvironment hdfsEnvironment, Path path)
private void deleteDirRecursive(Path path)
{
try {
HdfsContext context = new HdfsContext(identity.orElseGet(() ->
ConnectorIdentity.ofUser(DEFAULT_METASTORE_USER)));
hdfsEnvironment.getFileSystem(context, path).delete(path, true);
}
catch (IOException | RuntimeException e) {
Expand Down