rdblue commented on a change in pull request #1839:
URL: https://github.com/apache/iceberg/pull/1839#discussion_r533759461
##########
File path: core/src/main/java/org/apache/iceberg/CatalogUtil.java
##########
@@ -90,6 +94,31 @@ public static void dropTableData(FileIO io, TableMetadata
metadata) {
.run(io::deleteFile);
}
+ /**
+ * Drops all useless table directories.
+ *
+ * @param io a FileIO to use for deletes
+ * @param tableBaseLocation table base location
+ */
+ public static void dropTableBaseLocation(FileIO io, String
tableBaseLocation) {
+ try {
+ if (io instanceof HadoopFileIO) {
+ HadoopFileIO hadoopFileIO = (HadoopFileIO) io;
+ Configuration conf = hadoopFileIO.conf();
+ Path path = new Path(tableBaseLocation);
+ FileSystem fs = Util.getFs(path, conf);
+
+ // Because it might be a partitioned table, there might be a partition
path below the base path,
+ // so we need to delete recursively
+ fs.delete(path, true);
+ } else {
+ io.deleteFile(tableBaseLocation);
Review comment:
I don't think this is correct. The base location isn't a file, so
`deleteFile` should not be used. Instead, I think this should log an error that
there was no way to delete the base location and it was skipped.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]