Skip to content

Commit

Permalink
apacheGH-38782: [C++][FS][Azure] Do nothing for CreateDir("/container…
Browse files Browse the repository at this point in the history
…", true) (apache#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: apache#38782

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored and dgreiss committed Feb 17, 2024
1 parent e6403df commit 8f8f4df
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cpp/src/arrow/filesystem/azurefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8f8f4df

Please sign in to comment.