Skip to content

Commit 44593db

Browse files
authored
Merge pull request JanKaul#206 from Embucket/aosipov/s3_tables_drop_namespace
Implement drop namespace and namespace_exists
2 parents 599fb07 + c087921 commit 44593db

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use aws_sdk_s3tables::{
33
error::SdkError,
44
operation::{
55
create_namespace::CreateNamespaceError, create_table::CreateTableError,
6-
delete_table::DeleteTableError, get_table::GetTableError,
6+
delete_namespace::DeleteNamespaceError, delete_table::DeleteTableError,
7+
get_namespace::GetNamespaceError, get_table::GetTableError,
78
get_table_metadata_location::GetTableMetadataLocationError,
89
list_namespaces::ListNamespacesError, list_tables::ListTablesError,
910
update_table_metadata_location::UpdateTableMetadataLocationError,
@@ -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: 21 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,16 @@ 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
127+
.client
128+
.get_namespace()
129+
.table_bucket_arn(&self.arn)
130+
.namespace(namespace[0].as_str())
131+
.send()
132+
.await
133+
.map_err(Error::from)
134+
.is_ok())
118135
}
119136
async fn list_tabulars(&self, namespace: &Namespace) -> Result<Vec<Identifier>, IcebergError> {
120137
let mut tabulars = Vec::new();

0 commit comments

Comments
 (0)