nastra commented on code in PR #7194:
URL: https://github.com/apache/iceberg/pull/7194#discussion_r1147434137


##########
core/src/main/java/org/apache/iceberg/metrics/CommitReport.java:
##########
@@ -19,12 +19,15 @@
 package org.apache.iceberg.metrics;
 
 import java.util.Map;
+import org.apache.iceberg.TableOperations;
 import org.immutables.value.Value;
 
 /** A commit report that contains all relevant information from a Snapshot. */
 @Value.Immutable
 public interface CommitReport extends MetricsReport {
 
+  TableOperations tableOperations();

Review Comment:
   that shouldn't be added to a `CommitReport`. why is this required here?



##########
aws/src/main/java/org/apache/iceberg/aws/athena/RewriteUsingAthena.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.iceberg.aws.athena;
+
+import static 
org.apache.iceberg.TableProperties.AUTO_OPTIMIZE_REWRITE_DATA_FILES_ATHENA_DATABASE;
+import static 
org.apache.iceberg.TableProperties.AUTO_OPTIMIZE_REWRITE_DATA_FILES_ATHENA_DATABASE_DEFAULT;
+import static 
org.apache.iceberg.TableProperties.AUTO_OPTIMIZE_REWRITE_DATA_FILES_ATHENA_OUTPUT_BUCKET;
+import static 
org.apache.iceberg.TableProperties.AUTO_OPTIMIZE_REWRITE_DATA_FILES_ATHENA_OUTPUT_BUCKET_DEFAULT;
+import static 
org.apache.iceberg.TableProperties.AUTO_OPTIMIZE_REWRITE_DATA_FILES_SYNCHRONOUS_ENABLED;
+import static 
org.apache.iceberg.TableProperties.AUTO_OPTIMIZE_REWRITE_DATA_FILES_SYNCHRONOUS_ENABLED_DEFAULT;
+
+import org.apache.iceberg.TableOperations;
+import org.apache.iceberg.aws.AwsClientFactories;
+import org.apache.iceberg.aws.OptimizeTableUtil;
+import org.apache.iceberg.metrics.CommitReport;
+import org.apache.iceberg.metrics.MetricsReport;
+import org.apache.iceberg.metrics.Rewrite;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.services.athena.AthenaClient;
+import software.amazon.awssdk.services.athena.model.AthenaException;
+import software.amazon.awssdk.services.athena.model.GetQueryExecutionRequest;
+import software.amazon.awssdk.services.athena.model.GetQueryExecutionResponse;
+import software.amazon.awssdk.services.athena.model.QueryExecutionContext;
+import software.amazon.awssdk.services.athena.model.QueryExecutionState;
+import software.amazon.awssdk.services.athena.model.ResultConfiguration;
+import software.amazon.awssdk.services.athena.model.StartQueryExecutionRequest;
+import 
software.amazon.awssdk.services.athena.model.StartQueryExecutionResponse;
+
+/** An implementation of {@link Rewrite} to rewrite tables by launching 
OPTIMIZE jobs in Athena */
+public class RewriteUsingAthena implements Rewrite {
+  private static final Logger LOG = 
LoggerFactory.getLogger(RewriteUsingAthena.class);
+
+  private String tableName;
+
+  private AthenaClient athenaClient;
+
+  private boolean isSynchronousRewriteEnabled;
+
+  private String athenaOutputBucket;
+
+  private String athenaDatabase;
+
+  @Override
+  public void initialize(MetricsReport report) {
+    Preconditions.checkArgument(null != report, "Invalid metrics report: 
null");
+    TableOperations tableOperations = ((CommitReport) 
report).tableOperations();
+    this.tableName = OptimizeTableUtil.tableName(((CommitReport) 
report).tableName());
+    this.athenaClient = AwsClientFactories.defaultFactory().athena();
+    this.isSynchronousRewriteEnabled =
+        OptimizeTableUtil.propertyAsBoolean(
+            tableOperations,
+            AUTO_OPTIMIZE_REWRITE_DATA_FILES_SYNCHRONOUS_ENABLED,
+            AUTO_OPTIMIZE_REWRITE_DATA_FILES_SYNCHRONOUS_ENABLED_DEFAULT);
+    this.athenaOutputBucket =
+        OptimizeTableUtil.propertyAsString(
+            tableOperations,
+            AUTO_OPTIMIZE_REWRITE_DATA_FILES_ATHENA_OUTPUT_BUCKET,
+            AUTO_OPTIMIZE_REWRITE_DATA_FILES_ATHENA_OUTPUT_BUCKET_DEFAULT);
+    Preconditions.checkArgument(null != athenaOutputBucket, "Invalid output 
bucket: null");
+    this.athenaDatabase =
+        OptimizeTableUtil.propertyAsString(
+            tableOperations,
+            AUTO_OPTIMIZE_REWRITE_DATA_FILES_ATHENA_DATABASE,
+            AUTO_OPTIMIZE_REWRITE_DATA_FILES_ATHENA_DATABASE_DEFAULT);
+  }
+
+  @Override
+  public void rewrite(MetricsReport report) {
+    String queryExecutionId = submitAthenaQuery();

Review Comment:
   `report` doesn't seem to be used here



##########
core/src/main/java/org/apache/iceberg/TableProperties.java:
##########
@@ -359,4 +360,71 @@ private TableProperties() {}
 
   public static final String UPSERT_ENABLED = "write.upsert.enabled";
   public static final boolean UPSERT_ENABLED_DEFAULT = false;
+
+  /** @deprecated will be removed in 1.3.0, use the HMS_TABLE_OWNER constant 
from HiveCatalog */
+  @Deprecated public static final String HMS_TABLE_OWNER = 
"hive.metastore.table.owner";

Review Comment:
   why is this being added? probably a leftover from a rebase



##########
.palantir/revapi.yml:
##########
@@ -489,6 +489,9 @@ acceptedBreaks:
         \ @ org.apache.iceberg.SnapshotScan<ThisT, T extends 
org.apache.iceberg.ScanTask,\
         \ G extends org.apache.iceberg.ScanTaskGroup<T extends 
org.apache.iceberg.ScanTask>>"
       justification: "Removing deprecations for 1.3.0"
+    - code: "java.method.addedToInterface"
+      new: "method org.apache.iceberg.TableOperations 
org.apache.iceberg.metrics.CommitReport::tableOperations()"

Review Comment:
   as I mentioned further below, `TableOperations` shouldn't be added to 
`CommitReport`. A `CommitReport` represents some final results from a commit 
that happened



##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -440,6 +440,7 @@ private void notifyListeners() {
 
           reporter.report(
               ImmutableCommitReport.builder()
+                  .tableOperations(ops)

Review Comment:
   that shouldn't be added to a CommitReport



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to