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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergOutputCommitter.java:
##########
@@ -531,16 +538,25 @@ private void commitWrite(Table table, String branchName, 
Long snapshotId, long s
    * @param table The table we are changing
    * @param startTime The start time of the commit - used only for logging
    * @param results The object containing the new files
+   * @param rewritePolicy The rewrite policy to use for the insert overwrite 
commit
    */
-  private void commitOverwrite(Table table, String branchName, long startTime, 
FilesForCommit results) {
+  private void commitOverwrite(Table table, String branchName, long startTime, 
FilesForCommit results,
+      RewritePolicy rewritePolicy) {
     Preconditions.checkArgument(results.deleteFiles().isEmpty(), "Can not 
handle deletes with overwrite");
     if (!results.dataFiles().isEmpty()) {
-      ReplacePartitions overwrite = table.newReplacePartitions();
+      Transaction transaction = table.newTransaction();
+      if (rewritePolicy == RewritePolicy.ALL_PARTITIONS) {
+        DeleteFiles delete = transaction.newDelete();
+        delete.deleteFromRowFilter(Expressions.alwaysTrue());
+        delete.commit();
+      }
+      ReplacePartitions overwrite = transaction.newReplacePartitions();
       results.dataFiles().forEach(overwrite::addFile);
       if (StringUtils.isNotEmpty(branchName)) {
         overwrite.toBranch(HiveUtils.getTableSnapshotRef(branchName));
       }
       overwrite.commit();
+      transaction.commitTransaction();

Review Comment:
   there is no conflict validation and branch support, see commitWrite. 
However, we can do this in the next PRs.



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