leesf commented on a change in pull request #3209:
URL: https://github.com/apache/hudi/pull/3209#discussion_r663095778



##########
File path: 
hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HoodieHiveClient.java
##########
@@ -180,18 +180,31 @@ public void updateTableProperties(String tableName, 
Map<String, String> tablePro
     }
   }
 
-  private String constructAddPartitions(String tableName, List<String> 
partitions) {
+  private List<String> constructAddPartitions(String tableName, List<String> 
partitions) {
+    List<String> result = new ArrayList<>();
+    int batchSyncPartitionNum = Integer.parseInt(syncConfig.batchSyncNum);
     StringBuilder alterSQL = new StringBuilder("ALTER TABLE ");
     alterSQL.append(HIVE_ESCAPE_CHARACTER).append(syncConfig.databaseName)
             
.append(HIVE_ESCAPE_CHARACTER).append(".").append(HIVE_ESCAPE_CHARACTER)
             .append(tableName).append(HIVE_ESCAPE_CHARACTER).append(" ADD IF 
NOT EXISTS ");
-    for (String partition : partitions) {
-      String partitionClause = getPartitionClause(partition);
-      String fullPartitionPath = FSUtils.getPartitionPath(syncConfig.basePath, 
partition).toString();
+    for (int i = 0; i < partitions.size(); i++) {
+      String partitionClause = getPartitionClause(partitions.get(i));
+      String fullPartitionPath = FSUtils.getPartitionPath(syncConfig.basePath, 
partitions.get(i)).toString();
       alterSQL.append("  PARTITION (").append(partitionClause).append(") 
LOCATION '").append(fullPartitionPath)
           .append("' ");
+      if ((i + 1) % batchSyncPartitionNum == 0) {
+        result.add(alterSQL.toString());

Review comment:
       see duplicate lines in line#186, would we encapsulate a method such as 
`getAlterTablePrefix` ?




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