Skip to content

Commit 7df9682

Browse files
committed
Implement drop namespace and namespace_exists
1 parent 599fb07 commit 7df9682

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

catalogs/iceberg-s3tables-catalog/src/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use aws_sdk_s3tables::{
33
error::SdkError,
44
operation::{
55
create_namespace::CreateNamespaceError, create_table::CreateTableError,
6+
delete_namespace::DeleteNamespaceError, get_namespace::GetNamespaceError,
67
delete_table::DeleteTableError, get_table::GetTableError,
78
get_table_metadata_location::GetTableMetadataLocationError,
89
list_namespaces::ListNamespacesError, list_tables::ListTablesError,
@@ -21,6 +22,10 @@ pub enum Error {
2122
#[error(transparent)]
2223
CreateNamespace(#[from] SdkError<CreateNamespaceError, HttpResponse>),
2324
#[error(transparent)]
25+
DeleteNamespace(#[from] SdkError<DeleteNamespaceError, HttpResponse>),
26+
#[error(transparent)]
27+
GetNamespace(#[from] SdkError<GetNamespaceError, HttpResponse>),
28+
#[error(transparent)]
2429
ListTables(#[from] SdkError<ListTablesError, HttpResponse>),
2530
#[error(transparent)]
2631
ListNamespaces(#[from] SdkError<ListNamespacesError, HttpResponse>),

catalogs/iceberg-s3tables-catalog/src/lib.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,18 @@ impl Catalog for S3TablesCatalog {
9393
Ok(HashMap::new())
9494
}
9595
/// Drop a namespace in the catalog
96-
async fn drop_namespace(&self, _namespace: &Namespace) -> Result<(), IcebergError> {
97-
todo!()
96+
async fn drop_namespace(&self, namespace: &Namespace) -> Result<(), IcebergError> {
97+
self.client
98+
.delete_namespace()
99+
.table_bucket_arn(&self.arn)
100+
.namespace(namespace[0].as_str())
101+
.send()
102+
.await
103+
.map_err(Error::from)?;
104+
105+
Ok(())
98106
}
107+
99108
/// Load the namespace properties from the catalog
100109
async fn load_namespace(
101110
&self,
@@ -113,8 +122,15 @@ impl Catalog for S3TablesCatalog {
113122
todo!()
114123
}
115124
/// Check if a namespace exists
116-
async fn namespace_exists(&self, _namespace: &Namespace) -> Result<bool, IcebergError> {
117-
todo!()
125+
async fn namespace_exists(&self, namespace: &Namespace) -> Result<bool, IcebergError> {
126+
Ok(self.client
127+
.get_namespace()
128+
.table_bucket_arn(&self.arn)
129+
.namespace(namespace[0].as_str())
130+
.send()
131+
.await
132+
.map_err(Error::from)
133+
.is_ok())
118134
}
119135
async fn list_tabulars(&self, namespace: &Namespace) -> Result<Vec<Identifier>, IcebergError> {
120136
let mut tabulars = Vec::new();

0 commit comments

Comments
 (0)