Tom-Newton commented on code in PR #38793:
URL: https://github.com/apache/arrow/pull/38793#discussion_r1398952673


##########
cpp/src/arrow/filesystem/azurefs.cc:
##########
@@ -724,6 +724,59 @@ class AzureFileSystem::Impl {
 
     return Status::OK();
   }
+
+  Status DeleteDir(const AzureLocation& location) {
+    if (location.container.empty()) {
+      return Status::Invalid("Cannot delete an empty container");
+    }
+
+    if (location.path.empty()) {
+      auto container_client =
+          blob_service_client_->GetBlobContainerClient(location.container);
+      try {
+        auto response = container_client.Delete();
+        if (response.Value.Deleted) {
+          return Status::OK();
+        } else {
+          return StatusFromErrorResponse(
+              container_client.GetUrl(), response.RawResponse.get(),
+              "Failed to delete a container: " + location.container);
+        }
+      } catch (const Azure::Storage::StorageException& exception) {
+        return internal::ExceptionToStatus(
+            "Failed to delete a container: " + location.container + ": " +
+                container_client.GetUrl(),
+            exception);
+      }
+    }
+
+    ARROW_ASSIGN_OR_RAISE(auto hierarchical_namespace_enabled,
+                          hierarchical_namespace_.Enabled(location.container));
+    if (!hierarchical_namespace_enabled) {
+      // Without hierarchical namespace enabled Azure blob storage has no 
directories.
+      // Therefore we can't, and don't need to delete one.
+      return Status::OK();
+    }

Review Comment:
   There is no actual directory but there could be blobs that are considered 
part of this implied directory. I think in this case we should delete those 
blobs. 
   
   I think that will require listing blobs for the prefix 
(`internal::EnsureTrailingSlash(location.path)`) then iterating through the 
result and deleting all those blobs. 



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