jerryshao commented on code in PR #10189:
URL: https://github.com/apache/gravitino/pull/10189#discussion_r2893559964


##########
api/src/main/java/org/apache/gravitino/policy/IcebergCompactionContent.java:
##########
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.policy;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.regex.Pattern;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.MetadataObject;
+
+/** Built-in policy content for Iceberg compaction strategy. */
+public class IcebergCompactionContent implements PolicyContent {
+  /** Property key for strategy type. */
+  public static final String STRATEGY_TYPE_KEY = "strategy.type";
+  /** Strategy type value for compaction. */
+  public static final String STRATEGY_TYPE_VALUE = "compaction";
+  /** Property key for job template name. */
+  public static final String JOB_TEMPLATE_NAME_KEY = "job.template-name";
+  /** Built-in job template name for Iceberg rewrite data files. */
+  public static final String JOB_TEMPLATE_NAME_VALUE = 
"builtin-iceberg-rewrite-data-files";
+  /** Prefix for rewrite options propagated to job options. */
+  public static final String JOB_OPTIONS_PREFIX = "job.options.";
+  /** Rule key for trigger expression. */
+  public static final String TRIGGER_EXPR_KEY = "trigger-expr";
+  /** Rule key for score expression. */
+  public static final String SCORE_EXPR_KEY = "score-expr";
+  /** Rule key for minimum data file MSE threshold. */
+  public static final String MIN_DATA_FILE_MSE_KEY = "minDataFileMse";
+  /** Rule key for minimum delete file count threshold. */
+  public static final String MIN_DELETE_FILE_NUMBER_KEY = 
"minDeleteFileNumber";
+  /** Rule key for data file MSE score weight. */
+  public static final String DATA_FILE_MSE_WEIGHT_KEY = "dataFileMseWeight";
+  /** Rule key for delete file number score weight. */
+  public static final String DELETE_FILE_NUMBER_WEIGHT_KEY = 
"deleteFileNumberWeight";
+  /** Rule key for max partition number selected for compaction. */
+  public static final String MAX_PARTITION_NUM_KEY = "max-partition-num";
+  /** Metric name for data file MSE. */
+  public static final String DATA_FILE_MSE_METRIC = "custom-data-file-mse";

Review Comment:
   **Critical: metric name mismatch with the stats job (PR #10106)**
   
   `DATA_FILE_MSE_METRIC = "custom-data-file-mse"` but PR #10106 
(`IcebergUpdateStatsAndMetricsJob`) produces the metric as 
`"custom-datafile_mse"` (no hyphen before `mse`, and uses underscore). These 
two names must align or the trigger expression will never fire.
   
   Similarly, `DELETE_FILE_NUMBER_METRIC = "custom-delete-file-number"` does 
not match any metric produced by the stats job — the stats job emits 
`"custom-position_delete_files"` and `"custom-equality_delete_files"` as 
separate metrics, not an aggregated `custom-delete-file-number`. If the intent 
is "total delete file count", the stats job needs to produce this aggregated 
metric (or the expression needs to reference the individual metrics), otherwise 
this trigger will never evaluate to true.
   
   Please coordinate with PR #10106 to ensure the metric names are consistent 
end-to-end.



##########
maintenance/optimizer/src/main/java/org/apache/gravitino/maintenance/optimizer/recommender/strategy/GravitinoStrategy.java:
##########
@@ -43,7 +43,7 @@ public class GravitinoStrategy implements PartitionStrategy {
   /** Rule key for the partition table score aggregation mode. */
   public static final String PARTITION_TABLE_SCORE_MODE = 
"partition_table_score_mode";
   /** Rule key for the maximum number of partitions selected for execution. */
-  public static final String MAX_PARTITION_NUM = "max_partition_num";
+  public static final String MAX_PARTITION_NUM = "max-partition-num";

Review Comment:
   **Breaking change**: `MAX_PARTITION_NUM` was renamed from 
`"max_partition_num"` (underscore) to `"max-partition-num"` (hyphen). 
`GravitinoStrategy` is used for **all** `GravitinoPolicy`-based strategies, 
including existing custom policies. Any policy stored with `max_partition_num` 
in its rules will silently stop applying the partition limit and fall back to 
`DEFAULT_MAX_PARTITION_NUM = 100`. Please either preserve backward 
compatibility (read both keys, prefer the new one) or document this as an 
intentional breaking change requiring migration.



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