xiarixiaoyao commented on a change in pull request #4453:
URL: https://github.com/apache/hudi/pull/4453#discussion_r775762509



##########
File path: 
hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/ddl/HiveQueryDDLExecutor.java
##########
@@ -145,6 +148,30 @@ public void dropPartitionsToTable(String tableName, 
List<String> partitionsToDro
     }
   }
 
+  /**
+   * Remove "`" and "'"in partBuilder compared with getPartitionClause in 
QueryBasedDDLExecutor
+   * Use "/" as join delimiter
+   * @param partition
+   * @return String example as year=2021/month=06/day=25
+   */
+  public String getPartitionClauseForDrop(String partition) {
+    List<String> partitionValues = 
partitionValueExtractor.extractPartitionValuesInPath(partition);
+    ValidationUtils.checkArgument(config.partitionFields.size() == 
partitionValues.size(),
+        "Partition key parts " + config.partitionFields + " does not match 
with partition values " + partitionValues
+            + ". Check partition strategy. ");
+    List<String> partBuilder = new ArrayList<>();
+    for (int i = 0; i < config.partitionFields.size(); i++) {
+      String partitionValue = partitionValues.get(i);
+      // decode the partition before sync to hive to prevent multiple escapes 
of HIVE
+      if (config.decodePartition) {
+        // This is a decode operator for encode in 
KeyGenUtils#getRecordPartitionPath
+        partitionValue = 
PartitionPathEncodeUtils.unescapePathName(partitionValue);
+      }
+      partBuilder.add(config.partitionFields.get(i) + "=" + partitionValue);
+    }
+    return String.join("/", partBuilder);
+  }
+

Review comment:
       This method is basically the same as the method in HMSDDLExecutor.java . 
could we abstract out a unified method?




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