Skip to content

Commit

Permalink
Merge branch 'main' into simplify-state
Browse files Browse the repository at this point in the history
  • Loading branch information
roeap authored Dec 2, 2023
2 parents 7f7c5c1 + 4b16b9b commit 4eee0fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
27 changes: 11 additions & 16 deletions crates/deltalake-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,28 +710,23 @@ mod tests {
}

#[tokio::test()]
#[should_panic(expected = "does not exist or you don't have access!")]
async fn test_fail_fast_on_not_existing_path() {
use std::path::Path as FolderPath;

let path_str = "./tests/data/folder_doesnt_exist";
let non_existing_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();
let path_doesnt_exist = !FolderPath::new(non_existing_path_str).exists();
assert!(path_doesnt_exist);

match crate::open_table(path_str).await {
Ok(table) => Ok(table),
Err(e) => {
let path_still_doesnt_exist = !FolderPath::new(path_str).exists();
assert!(
path_still_doesnt_exist,
"Path exists for some reason, but it shouldn't"
);

Err(e)
}
}
.unwrap();
let error = crate::open_table(non_existing_path_str).await.unwrap_err();
let _expected_error_msg = format!(
"Local path \"{}\" does not exist or you don't have access!",
non_existing_path_str
);
assert!(matches!(
error,
DeltaTableError::InvalidTableLocation(_expected_error_msg),
))
}
}
6 changes: 5 additions & 1 deletion crates/deltalake-core/src/table/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ impl DeltaTableBuilder {

if let UriType::LocalPath(path) = resolve_uri_type(table_uri)? {
if !path.exists() {
panic!("Path \"{table_uri}\" does not exist or you don't have access!");
let msg = format!(
"Local path \"{}\" does not exist or you don't have access!",
table_uri
);
return Err(DeltaTableError::InvalidTableLocation(msg));
}
}

Expand Down

0 comments on commit 4eee0fd

Please sign in to comment.