mkroll-db commented on code in PR #3309:
URL: https://github.com/apache/iceberg-rust/pull/3309#discussion_r4530796125


##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -1168,6 +1208,52 @@ impl Catalog for SqlCatalog {
         Ok(builder.build()?)
     }
 
+    async fn unregister_table(&self, table_ident: &TableIdent) -> 
Result<Table> {
+        let rows = self
+            .fetch_rows(
+                &format!(
+                    "SELECT {CATALOG_FIELD_METADATA_LOCATION_PROP}
+                     FROM {CATALOG_TABLE_NAME}
+                     WHERE {CATALOG_FIELD_CATALOG_NAME} = ?
+                      AND {CATALOG_FIELD_TABLE_NAME} = ?
+                      AND {CATALOG_FIELD_TABLE_NAMESPACE} = ?
+                      {}",
+                    self.schema_version.record_type_filter()
+                ),
+                vec![
+                    Some(&self.name),
+                    Some(table_ident.name()),
+                    Some(&table_ident.namespace().join(".")),
+                ],
+            )
+            .await?;
+        let row = rows.first().ok_or_else(|| {
+            Error::new(
+                ErrorKind::TableNotFound,
+                format!("No such table: {table_ident}"),
+            )
+        })?;
+        let metadata_location = row
+            .try_get::<String, _>(CATALOG_FIELD_METADATA_LOCATION_PROP)
+            .map_err(from_sqlx_error)?;
+
+        self.remove_table_at_location(table_ident, &metadata_location)

Review Comment:
   Yes this is much better. I fixed it accordingly.



##########
crates/iceberg/src/catalog/memory/catalog.rs:
##########
@@ -399,6 +399,26 @@ impl Catalog for MemoryCatalog {
         builder.build()
     }
 
+    async fn unregister_table(&self, table_ident: &TableIdent) -> 
Result<Table> {
+        let metadata_location = {
+            let mut root_namespace_state = 
self.root_namespace_state.lock().await;
+            root_namespace_state.remove_existing_table(table_ident)?

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to