emkornfield commented on code in PR #1584:
URL: https://github.com/apache/iceberg-rust/pull/1584#discussion_r2289354812


##########
crates/catalog/glue/src/catalog.rs:
##########
@@ -635,10 +637,56 @@ impl Catalog for GlueCatalog {
         ))
     }
 
-    async fn update_table(&self, _commit: TableCommit) -> Result<Table> {
-        Err(Error::new(
-            ErrorKind::FeatureUnsupported,
-            "Updating a table is not supported yet",
-        ))
+    async fn update_table(&self, commit: TableCommit) -> Result<Table> {
+        let table_ident = commit.identifier().clone();
+        let table_namespace = validate_namespace(table_ident.namespace())?;
+        let current_table = self.load_table(&table_ident).await?;
+        let current_metadata_location = 
current_table.metadata_location_result()?.to_string();
+
+        let staged_table = commit.apply(current_table)?;
+        let staged_metadata_location = 
staged_table.metadata_location_result()?;
+
+        // Write new metadata
+        staged_table
+            .metadata()
+            .write_to(staged_table.file_io(), staged_metadata_location)
+            .await?;
+
+        // Persist staged table to Glue
+        let builder = self
+            .client
+            .0
+            .update_table()
+            .database_name(table_namespace)
+            .set_skip_archive(Some(true)) // todo make this configurable
+            .table_input(convert_to_glue_table(
+                table_ident.name(),
+                staged_metadata_location.to_string(),
+                staged_table.metadata(),
+                staged_table.metadata().properties(),
+                Some(current_metadata_location),
+            )?);
+        let builder = with_catalog_id!(builder, self.config);
+        let _ = builder.send().await.map_err(|e| {
+            let error = e.into_service_error();
+            match error {
+                UpdateTableError::EntityNotFoundException(_) => Error::new(
+                    ErrorKind::TableNotFound,
+                    format!("Table {table_ident} is not found"),
+                ),
+                UpdateTableError::ConcurrentModificationException(_) => 
Error::new(
+                    ErrorKind::CatalogCommitConflicts,
+                    format!("Commit failed for table: {table_ident}"),
+                )
+                .with_retryable(true),
+                _ => Error::new(
+                    ErrorKind::Unexpected,
+                    "Operation failed for hitting aws sdk error",

Review Comment:
   ```suggestion
                       "Operation failed for hitting AWS SDK error",
   ```
   nit



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