Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-38703: [C++][FS][Azure] Implement DeleteFile() #39692

Closed
wants to merge 5 commits into from
Closed

GH-38703: [C++][FS][Azure] Implement DeleteFile() #39692

wants to merge 5 commits into from

Conversation

av8or1
Copy link
Contributor

@av8or1 av8or1 commented Jan 18, 2024

Rationale for this change

What changes are included in this PR?

Resolution of the conflict in ~cpp/src/arrow/filesystem/azurefs_test.cc. Here are my original comments regarding this modification in the abstract:
Modified:
~cpp/src/arrow/filesystem/azurerefs.cc
~cpp/src/arrow/filesystem/azurerefs_test.cc
These modifications implement the method and provide regression testing, respectively.

Are these changes tested?

I tested the modification by creating a file via the web browser on our internal ADLS, then ran a sample program that deleted the file. I added three regression tests to cover the use case scenarios of:

A valid delete attempt, where "valid" means that the file exists and is indeed a file
An intentional failure where a file delete is attempted, but the file does not exist
An intentional failure where a file delete is attempted, but the target is not a file

Regarding the modifications to the regression suite... I don't know how to run the Arrow regression. Need instructions. The original code in ~cpp/src/arrow/filesystem/azurefs.cc is tested, as previously mentioned in #39648.

Are there any user-facing changes?

Overall, this code includes a new method to delete a file on an Azure server. That is likely something that will need inclusion in the documentation, but as this is my first PR, I can't say how things are usually done with the Arrow project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this needless file?

Copy link
Contributor Author

@av8or1 av8or1 Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needless file? Is this not the regression testing? Should I not update this file when adding functionality such as this? Mind you, I ask only because I am trying to learn the process used here. I am willing to back out my changes, just wanting to learn. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that /azurefs_test.cc in the top-level directory is needless.
Because it should be at cpp/src/arrow/filesystem/azurefs_test.cc. (And it already exists.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, things picked up at work. Just now revisiting this. OK, I am confused. The version of azurefs_test.cc that I submitted was located within cpp/src/arrow/filesystem/ ... as was azurefs.cc. So where did I go wrong with this?

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Jan 19, 2024

auto file_client =
datalake_service_client_->GetFileSystemClient(location.container)
.GetDirectoryClient(directory).GetFileClient(file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can GetFileClient(location.path) from filesystem client -- you don't have to create a directory client.

Comment on lines +1755 to +1758
return internal::ExceptionToStatus(
"Failed to delete a file: " + location.all + ": " +
file_client.GetUrl(),
exception);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while since you rebased. This function expects exception to be the first parameter now and all the other components can be passed as separate arguments, so you don't have to + the strings yourself.

.GetDirectoryClient(directory).GetFileClient(file);

try {
auto response = file_client.DeleteIfExists();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use Delete() you get an exception when the file doesn't exist and then you can return PathNotFound(location).

@av8or1
Copy link
Contributor Author

av8or1 commented Jan 25, 2024

Based on the feedback from kou and felipecrv, I think I'll close this PR, reset my local repo, incorporate felipecrv's feedback and then open a new PR. Thanks

@av8or1 av8or1 closed this Jan 25, 2024
@av8or1 av8or1 deleted the delete-file-branch branch January 25, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[C++][FS][Azure] Implement DeleteFile()
3 participants