This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 7df1cdd0fe GH-38782: [C++][FS][Azure] Do nothing for 
CreateDir("/container", true) (#38783)
7df1cdd0fe is described below

commit 7df1cdd0fe364f86eca15bfc482210994ba8e2f0
Author: Sutou Kouhei <[email protected]>
AuthorDate: Sun Nov 19 19:46:30 2023 +0900

    GH-38782: [C++][FS][Azure] Do nothing for CreateDir("/container", true) 
(#38783)
    
    ### Rationale for this change
    
    It's failed with hierarchical namespace support. And we don't need to do 
nothing for the case because container must exist in the case.
    
    ### What changes are included in this PR?
    
    Add a missing `location.path.empty()` check.
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    Yes.
    * Closes: #38782
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/src/arrow/filesystem/azurefs.cc | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/cpp/src/arrow/filesystem/azurefs.cc 
b/cpp/src/arrow/filesystem/azurefs.cc
index 91e6c22255..bd0e353e4a 100644
--- a/cpp/src/arrow/filesystem/azurefs.cc
+++ b/cpp/src/arrow/filesystem/azurefs.cc
@@ -708,16 +708,18 @@ class AzureFileSystem::Impl {
       return Status::OK();
     }
 
-    auto directory_client =
-        datalake_service_client_->GetFileSystemClient(location.container)
-            .GetDirectoryClient(location.path);
-    try {
-      directory_client.CreateIfNotExists();
-    } catch (const Azure::Storage::StorageException& exception) {
-      return internal::ExceptionToStatus(
-          "Failed to create a directory: " + location.path + " (" +
-              directory_client.GetUrl() + ")",
-          exception);
+    if (!location.path.empty()) {
+      auto directory_client =
+          datalake_service_client_->GetFileSystemClient(location.container)
+              .GetDirectoryClient(location.path);
+      try {
+        directory_client.CreateIfNotExists();
+      } catch (const Azure::Storage::StorageException& exception) {
+        return internal::ExceptionToStatus(
+            "Failed to create a directory: " + location.path + " (" +
+                directory_client.GetUrl() + ")",
+            exception);
+      }
     }
 
     return Status::OK();

Reply via email to