FANNG1 commented on code in PR #10106:
URL: https://github.com/apache/gravitino/pull/10106#discussion_r2889662096


##########
maintenance/optimizer/src/main/java/org/apache/gravitino/maintenance/optimizer/command/SubmitUpdateStatsJobCommand.java:
##########
@@ -0,0 +1,248 @@
+/*
+ * 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.maintenance.optimizer.command;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TreeMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.client.GravitinoClient;
+import org.apache.gravitino.job.JobHandle;
+import org.apache.gravitino.maintenance.optimizer.common.conf.OptimizerConfig;
+import 
org.apache.gravitino.maintenance.optimizer.common.util.GravitinoClientUtils;
+import 
org.apache.gravitino.maintenance.optimizer.common.util.IcebergSparkConfigUtils;
+
+/**
+ * Handles CLI command {@code submit-update-stats-job} for submitting built-in 
Iceberg update stats
+ * jobs directly from optimizer CLI.
+ */
+public class SubmitUpdateStatsJobCommand implements OptimizerCommandExecutor {
+
+  private static final String JOB_TEMPLATE_NAME = 
"builtin-iceberg-update-stats";
+  private static final String DEFAULT_UPDATE_MODE = "stats";
+  private static final String OPTION_UPDATER_OPTIONS = "updater-options";
+  private static final String OPTION_SPARK_CONF = "spark-conf";
+
+  private static final ObjectMapper MAPPER = new ObjectMapper();
+
+  @Override
+  public void execute(OptimizerCommandContext context) throws Exception {
+    Map<String, String> submitterConfigs = 
context.optimizerEnv().config().jobSubmitterConfigs();
+
+    List<TableTarget> tableTargets =
+        parseTableTargets(
+            context.identifiers(),
+            
context.optimizerEnv().config().get(OptimizerConfig.GRAVITINO_DEFAULT_CATALOG_CONFIG));
+
+    String updateMode =
+        parseUpdateMode(
+            resolveScalarOption(context.updateMode(), 
submitterConfigs.get("update_mode")));
+
+    String updaterOptionsJson =
+        resolveJsonOption(context.updaterOptions(), 
submitterConfigs.get("updater_options"));
+    String sparkConfJson =
+        resolveJsonOption(context.sparkConf(), 
submitterConfigs.get("spark_conf"));
+
+    Map<String, String> updaterOptions =
+        IcebergSparkConfigUtils.parseFlatJsonMap(updaterOptionsJson, 
OPTION_UPDATER_OPTIONS);
+    Map<String, String> sparkConfigs =
+        IcebergSparkConfigUtils.parseFlatJsonMap(sparkConfJson, 
OPTION_SPARK_CONF);
+
+    validateUpdaterOptions(updateMode, updaterOptions);
+    validateSparkConfigs(tableTargets, sparkConfigs);
+
+    if (context.dryRun()) {
+      for (TableTarget tableTarget : tableTargets) {
+        Map<String, String> jobConfig =
+            buildJobConfig(tableTarget, updateMode, updaterOptions, 
sparkConfigs);
+        context
+            .output()
+            .printf(
+                "DRY-RUN: identifier=%s jobTemplate=%s jobConfig=%s%n",
+                tableTarget.fullIdentifier, JOB_TEMPLATE_NAME, jobConfig);
+      }

Review Comment:
   Thanks for calling this out. We discussed this and intentionally did not 
apply log redaction in this PR to keep the CLI output behavior unchanged for 
now. I agree this is a valid security hardening item, but we plan to handle it 
in a follow-up with a clearer redaction policy (to avoid partial masking 
pitfalls).



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