niranjan-1408 commented on code in PR #19762:
URL: https://github.com/apache/hudi/pull/19762#discussion_r3868604941


##########
hudi-aws/src/test/java/org/apache/hudi/aws/sync/TestAWSGlueSyncClient.java:
##########
@@ -909,4 +912,81 @@ private CompletableFuture<GetTableResponse> 
getTableWithDefaultProps(String tabl
         .build();
     return CompletableFuture.completedFuture(response);
   }
+
+  @ParameterizedTest
+  @ValueSource(strings = {"2024-01-15", "datestr=2024-01-15", "2024/01/15"})
+  void 
testUpdateTableSchema_cascadePreservesGlueRecordedPartitionLocation(String 
partitionDir) {
+    String tableName = GlueTestUtil.TABLE_NAME;
+    String basePath = 
GlueTestUtil.getHiveSyncConfig().getString(META_SYNC_BASE_PATH);
+    String partitionLocation = new StoragePath(basePath, 
partitionDir).toString();
+
+    Table table = Table.builder()
+        .name(tableName)
+        .databaseName(GlueTestUtil.DB_NAME)
+        .storageDescriptor(StorageDescriptor.builder()
+            .location(basePath)
+            .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()));
+
+    software.amazon.awssdk.services.glue.model.Partition gluePartition =
+        software.amazon.awssdk.services.glue.model.Partition.builder()
+            .values("2024-01-15")
+            
.storageDescriptor(StorageDescriptor.builder().location(partitionLocation).build())
+            .build();
+    when(mockAwsGlue.getPartitions(any(GetPartitionsRequest.class)))
+        .thenReturn(CompletableFuture.completedFuture(
+            
GetPartitionsResponse.builder().partitions(gluePartition).nextToken(null).build()));
+
+    ArgumentCaptor<BatchUpdatePartitionRequest> captor = 
ArgumentCaptor.forClass(BatchUpdatePartitionRequest.class);
+    when(mockAwsGlue.batchUpdatePartition(captor.capture()))
+        
.thenReturn(CompletableFuture.completedFuture(BatchUpdatePartitionResponse.builder().build()));
+
+    HoodieSchema schema = GlueTestUtil.getSimpleSchema();
+    SchemaDifference schemaDiff = SchemaDifference.newBuilder(schema, new 
HashMap<>())
+        .updateTableColumn("name", "string")
+        .build();
+
+    awsGlueSyncClient.updateTableSchema(tableName, schema, schemaDiff);
+
+    List<BatchUpdatePartitionRequestEntry> entries = 
captor.getValue().entries();
+    assertEquals(1, entries.size());
+    assertEquals(partitionLocation, 
entries.get(0).partitionInput().storageDescriptor().location());
+    assertEquals(Collections.singletonList("2024-01-15"), 
entries.get(0).partitionValueList());
+    assertEquals(table.storageDescriptor().columns(),
+        entries.get(0).partitionInput().storageDescriptor().columns());

Review Comment:
   done in 
[0bfc756](https://github.com/apache/hudi/pull/19762/commits/0bfc756782857e6af91d7ad5b5c580294526a2c9)



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

Reply via email to