deniskuzZ commented on code in PR #5591:
URL: https://github.com/apache/hive/pull/5591#discussion_r2082322365


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java:
##########
@@ -1729,4 +1753,68 @@ public static List<String> 
getColumnNames(List<FieldSchema> cols) {
   public static boolean isCompactionTxn(TxnType txnType) {
     return TxnType.COMPACTION.equals(txnType) || 
TxnType.REBALANCE_COMPACTION.equals(txnType);
   }
+
+  /**
+   * When using msck repair table with custom partitioning patterns, we need 
to capture
+   * the partition keys from the pattern, and use those to construct a regex 
which will
+   * match the paths and extract the partition key values.*/
+  public static class DynamicPartitioningCustomPattern {
+
+    private final String customPattern;
+    private final Pattern partitionCapturePattern;
+    private final List<String> partitionColumns;
+
+    private DynamicPartitioningCustomPattern(String customPattern, Pattern 
partitionCapturePattern, List<String> partitionColumns) {
+      this.customPattern = customPattern;
+      this.partitionCapturePattern = partitionCapturePattern;
+      this.partitionColumns = partitionColumns;
+    }
+
+    /**
+     * @return stored custom pattern string
+    * */
+    public String getCustomPattern() {
+      return customPattern;
+    }
+
+    /**
+     * @return stored custom pattern regex matcher
+     * */
+    public Pattern getPartitionCapturePattern() {
+      return partitionCapturePattern;
+    }
+
+    /**
+     * @return list of partition key columns
+     * */
+    public List<String> getPartitionColumns() {
+      return partitionColumns;
+    }
+
+    public static class Builder {
+      private String customPattern;
+
+      public Builder setCustomPattern(String customPattern) {
+        this.customPattern = customPattern;
+        return this;
+      }
+
+      /**
+       * Constructs the regex to match the partition values in a path based on 
the custom pattern.
+       *
+       * @return custom partition pattern matcher */
+      public DynamicPartitioningCustomPattern build() {
+        Pattern stringPattern = 
Pattern.compile("(\\$\\{)([^\\s/\\{\\}\\\\]+)(\\})");

Review Comment:
   move to constant



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to