Skip to content

Commit

Permalink
Fix get_latest_version returning version < 0. (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
zijie0 authored Aug 9, 2021
1 parent 61e2941 commit 4fd43cb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rust/src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@ impl DeltaTable {
match e {
StorageError::NotFound => {
version -= 1;
if version < 0 {
let err = format!(
"No snapshot or version 0 found, perhaps {} is an empty dir?",
self.table_uri
);
return Err(DeltaTableError::NotATable(err));
}
}
_ => return Err(DeltaTableError::from(e)),
}
Expand Down
12 changes: 12 additions & 0 deletions rust/tests/read_error_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ async fn read_empty_folder() {
result.unwrap_err(),
deltalake::DeltaTableError::NotATable(_),
));

let dir = env::temp_dir();
let result = deltalake::open_table_with_ds(
&dir.into_os_string().into_string().unwrap(),
"2021-08-09T13:18:31+08:00",
)
.await;

assert!(matches!(
result.unwrap_err(),
deltalake::DeltaTableError::NotATable(_),
));
}

0 comments on commit 4fd43cb

Please sign in to comment.