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


##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -1168,6 +1209,60 @@ impl Catalog for SqlCatalog {
         Ok(builder.build()?)
     }
 
+    async fn unregister_table(&self, table_ident: &TableIdent) -> 
Result<Table> {
+        if self.schema_version != SchemaVersion::V1 {
+            return Err(Error::new(
+                ErrorKind::FeatureUnsupported,
+                format!(
+                    "Table unregistration is not supported for SQL catalog 
schema version {}",
+                    self.schema_version
+                ),
+            ));
+        }
+
+        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 Some(row) = rows.first() else {
+            return no_such_table_err(table_ident);
+        };
+        let metadata_location = row
+            .try_get::<String, _>(CATALOG_FIELD_METADATA_LOCATION_PROP)
+            .map_err(from_sqlx_error)?;
+
+        // read before (re-)moving, this way a failed read keeps the table 
registered
+        let metadata = TableMetadata::read_from(&self.fileio, 
&metadata_location).await?;

Review Comment:
   Done.



-- 
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