diff --git a/rust/src/delta.rs b/rust/src/delta.rs index dcb55b9bda..bcdc39aef8 100644 --- a/rust/src/delta.rs +++ b/rust/src/delta.rs @@ -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)), } diff --git a/rust/tests/read_error_test.rs b/rust/tests/read_error_test.rs index 9207938261..a99ed2e638 100644 --- a/rust/tests/read_error_test.rs +++ b/rust/tests/read_error_test.rs @@ -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(_), + )); }