You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by da...@apache.org on 2026/08/28 02:22:47 UTC

(hudi) branch master updated: fix(sync): drop the duplicate UpdateTable in updateTableSchema (#19762)

This is an automated email from the ASF dual-hosted git repository.

danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 863f84a08864 fix(sync): drop the duplicate UpdateTable in updateTableSchema (#19762)
863f84a08864 is described below

commit 863f84a08864ac4916c31b1412ec1eab737a1b73
Author: niranjan-1408 <ni...@onehouse.ai>
AuthorDate: Thu Aug 27 19:22:41 2026 -0700

    fix(sync): drop the duplicate UpdateTable in updateTableSchema (#19762)
    
    updateTableSchema issued the same UpdateTable request object twice. The second call
    sat outside the if (cascade) block, so it fired unconditionally, including on
    non-partitioned tables where cascade is false.
    
    Nothing between the two calls mutates the request, and the cascade branch writes
    partitions rather than the table, so the second call was a no-op that Glue still
    counted as a new table version. Every schema change therefore consumed two table
    versions where one would do.
    
    The first call is kept rather than the second because the cascade re-reads the table
    to source the columns it propagates: with the update first it sees the new columns,
    whereas keeping only the second would have it propagate stale ones.
---
 .../hudi/aws/sync/AWSGlueCatalogSyncClient.java    |  1 -
 .../hudi/aws/sync/TestAWSGlueSyncClient.java       | 28 ++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/hudi-aws/src/main/java/org/apache/hudi/aws/sync/AWSGlueCatalogSyncClient.java b/hudi-aws/src/main/java/org/apache/hudi/aws/sync/AWSGlueCatalogSyncClient.java
index f587882dfdf8..342b75783d96 100644
--- a/hudi-aws/src/main/java/org/apache/hudi/aws/sync/AWSGlueCatalogSyncClient.java
+++ b/hudi-aws/src/main/java/org/apache/hudi/aws/sync/AWSGlueCatalogSyncClient.java
@@ -628,7 +628,6 @@ public class AWSGlueCatalogSyncClient extends HoodieSyncClient {
       if (cascade) {
         cascadeColumnsToPartitions(tableName, getAllPartitions(tableName));
       }
-      awsGlue.updateTable(request).get();
     } catch (Exception e) {
       throw new HoodieGlueSyncException("Fail to update definition for table " + tableId(databaseName, tableName), e);
     }
diff --git a/hudi-aws/src/test/java/org/apache/hudi/aws/sync/TestAWSGlueSyncClient.java b/hudi-aws/src/test/java/org/apache/hudi/aws/sync/TestAWSGlueSyncClient.java
index 6400198f0ac7..5ff5ca1c738b 100644
--- a/hudi-aws/src/test/java/org/apache/hudi/aws/sync/TestAWSGlueSyncClient.java
+++ b/hudi-aws/src/test/java/org/apache/hudi/aws/sync/TestAWSGlueSyncClient.java
@@ -982,4 +982,32 @@ class TestAWSGlueSyncClient {
     inOrder.verify(mockAwsGlue).updateTable(any(UpdateTableRequest.class));
     inOrder.verify(mockAwsGlue).batchUpdatePartition(any(BatchUpdatePartitionRequest.class));
   }
+
+  @Test
+  void testUpdateTableSchema_issuesOneUpdateTable() {
+    String tableName = GlueTestUtil.TABLE_NAME;
+    Table table = Table.builder()
+        .name(tableName)
+        .databaseName(GlueTestUtil.DB_NAME)
+        .storageDescriptor(StorageDescriptor.builder()
+            .location("s3://base")
+            .columns(Column.builder().name("name").type("string").build())
+            .build())
+        .partitionKeys(Column.builder().name("datestr").type("string").build())
+        .build();
+    when(mockAwsGlue.getTable(any(GetTableRequest.class)))
+        .thenReturn(CompletableFuture.completedFuture(GetTableResponse.builder().table(table).build()));
+    when(mockAwsGlue.updateTable(any(UpdateTableRequest.class)))
+        .thenReturn(CompletableFuture.completedFuture(UpdateTableResponse.builder().build()));
+
+    HoodieSchema schema = GlueTestUtil.getSimpleSchema();
+    SchemaDifference schemaDiff = SchemaDifference.newBuilder(schema, new HashMap<>())
+        .addTableColumn("added", "string")
+        .build();
+
+    awsGlueSyncClient.updateTableSchema(tableName, schema, schemaDiff);
+
+    verify(mockAwsGlue, times(1)).updateTable(any(UpdateTableRequest.class));
+    verify(mockAwsGlue, never()).batchUpdatePartition(any(BatchUpdatePartitionRequest.class));
+  }
 }