From 5cbd979455d792cf6c6d8ed27e13daaeabc20e2f Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Tue, 1 Sep 2026 05:02:40 +0800 Subject: [PATCH] fix: preserve namespace drop errors (#4099) ## Summary - preserve typed namespace errors returned by `drop_table` - return `TableNotFound` when dropping an absent namespace table - cover repeated drop behavior in the namespace database test ## Validation - `cargo test --quiet --features remote -p lancedb database::namespace::tests::test_namespace_drop_table --lib` - `cargo clippy --quiet --features remote -p lancedb --lib --tests -- -D warnings` ## Context Sophon SQL implements `DROP TABLE IF EXISTS` by matching `lancedb::Error::TableNotFound`. The namespace database previously wrapped this error as `Runtime`, causing cleanup to fail and mask an earlier statement error. --- rust/lancedb/src/database/namespace.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rust/lancedb/src/database/namespace.rs b/rust/lancedb/src/database/namespace.rs index 250d933f6..5ca720e85 100644 --- a/rust/lancedb/src/database/namespace.rs +++ b/rust/lancedb/src/database/namespace.rs @@ -539,9 +539,7 @@ impl Database for LanceNamespaceDatabase { self.namespace .drop_table(drop_request) .await - .map_err(|e| Error::Runtime { - message: format!("Failed to drop table: {}", e), - })?; + .map_err(|e| map_namespace_lance_error(e, name))?; Ok(()) } @@ -1495,6 +1493,15 @@ mod tests { .expect("Failed to list tables"); assert!(!table_names_after.contains(&"drop_test".to_string())); + let error = conn + .drop_table("drop_test", &["test_ns".into()]) + .await + .expect_err("dropping a missing table should fail"); + assert!( + matches!(error, Error::TableNotFound { ref name, .. } if name == "drop_test"), + "expected TableNotFound, got: {error:?}" + ); + // Verify: Cannot open dropped table let open_result = conn.open_table("drop_test").execute().await; assert!(open_result.is_err());