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

Load DeltaTable from non-existing folder causing empty folder creation #1916

Closed
dimonchik-suvorov opened this issue Nov 28, 2023 · 0 comments · Fixed by #1917
Closed

Load DeltaTable from non-existing folder causing empty folder creation #1916

dimonchik-suvorov opened this issue Nov 28, 2023 · 0 comments · Fixed by #1917
Labels
bug Something isn't working

Comments

@dimonchik-suvorov
Copy link
Contributor

dimonchik-suvorov commented Nov 28, 2023

Environment

Delta-rs version: 0.17.0

Binding: rust

Environment:

  • Cloud provider:
  • OS: macos
  • Other:

Bug

What happened:
New folder created at the beginning of deltalake::open_table("./tests/data/folder_doesnt_exist").await? which isn't expected and only then it fails with NotATable error which is expected. It uses ensure_table_uri function in the build_storage function during load of Delta Table. And ensure_table_uri creates new folder (recursively) if folder doesn't exist. Moreover it doesn't remove that folder at the end so you end up with failed function call and new folder.
What you expected to happen:
I guess it will be nice to fail fast in case user is trying to load some path which isn't even exists not to mention it can't be a table 🙂...
How to reproduce it:
deltalake::open_table("./tests/data/folder_doesnt_exist").await? and you will see that folder_not_exists will be created.
More details:
image

crates/deltalake-core/src/lib.rs

    #[tokio::test()]
    #[should_panic(expected = "NotATable(\"No snapshot or version 0 found")]
    async fn test_load_non_existing_folder() {
        use std::path::Path as FolderPath;
        use std::fs;

        let path_str = "./tests/data/folder_doesnt_exist";

        // Check that there is no such path at the beginning
        let path_doesnt_exist = !FolderPath::new(path_str).exists();
        assert!(path_doesnt_exist);

        let result = match crate::open_table(path_str).await {
            Ok(table) => Ok(table),
            Err(e) => {
                let newly_created_folder_path = FolderPath::new(path_str);
                assert!(newly_created_folder_path.exists());
                // This needs because it actually creates a folder and we need to remove it at the end of the test 😁
                fs::remove_dir(newly_created_folder_path)
                    .expect("can't remove folder for some reason");
                Err(e)
            }
        };
        result.unwrap();
    }
@dimonchik-suvorov dimonchik-suvorov added the bug Something isn't working label Nov 28, 2023
dimonchik-suvorov pushed a commit to dimonchik-suvorov/delta-rs that referenced this issue Nov 28, 2023
# Description
Save user from ending up with failed `load` function call and new folder created - failing fast in case user is trying to load some path that doesn't exist

# Related Issue(s)
- closes delta-io#1916
rtyler pushed a commit that referenced this issue Nov 29, 2023
# Description
Save user from ending up with failed `load` function call and new folder created - failing fast in case user is trying to load some path that doesn't exist

# Related Issue(s)
- closes #1916
ion-elgreco pushed a commit to ion-elgreco/delta-rs that referenced this issue Dec 1, 2023
# Description
Save user from ending up with failed `load` function call and new folder created - failing fast in case user is trying to load some path that doesn't exist

# Related Issue(s)
- closes delta-io#1916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant