Skip to content

Commit

Permalink
Move fn to DeltaTable, replace match with Ok
Browse files Browse the repository at this point in the history
  • Loading branch information
omkar-foss authored and ion-elgreco committed Jul 31, 2024
1 parent ceeffd8 commit 6f6769d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
6 changes: 0 additions & 6 deletions crates/core/src/table/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,6 @@ impl DeltaTableBuilder {
}
Ok(table)
}

/// Check if the [`DeltaTable`] exists
pub async fn verify_deltatable_existence(self) -> DeltaResult<bool> {
let table = self.build()?;
table.log_store.is_delta_table_location().await
}
}

enum UriType {
Expand Down
5 changes: 5 additions & 0 deletions crates/core/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ impl DeltaTable {
self.log_store.object_store()
}

/// Check if the [`DeltaTable`] exists
pub async fn verify_deltatable_existence(&self) -> DeltaResult<bool> {
self.log_store.is_delta_table_location().await
}

/// The URI of the underlying data
pub fn table_uri(&self) -> String {
self.log_store.root_uri()
Expand Down
16 changes: 8 additions & 8 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ impl RawDeltaTable {
if let Some(storage_options) = storage_options {
builder = builder.with_storage_options(storage_options)
}
let res = rt()
.block_on(builder.verify_deltatable_existence())
.map_err(PythonError::from);
match res {
Ok(true) => Ok(true),
Ok(false) => Ok(false),
Err(err) => Err(err)?,
}
Ok(rt()
.block_on(async {
match builder.build() {
Ok(table) => table.verify_deltatable_existence().await,
Err(err) => Err(err),
}
})
.map_err(PythonError::from)?)
}

pub fn table_uri(&self) -> PyResult<String> {
Expand Down

0 comments on commit 6f6769d

Please sign in to comment.