diff --git a/api/src/main/java/org/apache/iceberg/RewriteFiles.java b/api/src/main/java/org/apache/iceberg/RewriteFiles.java index c392c7118d8a..46545b8c027e 100644 --- a/api/src/main/java/org/apache/iceberg/RewriteFiles.java +++ b/api/src/main/java/org/apache/iceberg/RewriteFiles.java @@ -32,15 +32,93 @@ * will be resolved by applying the changes to the new latest snapshot and reattempting the commit. * If any of the deleted files are no longer in the latest snapshot when reattempting, the commit * will throw a {@link ValidationException}. + * + *
Note that the new state of the table after each rewrite must be logically equivalent to the
+ * original table state.
*/
public interface RewriteFiles extends SnapshotUpdate This rewrite operation may change the size or layout of the data files. When applicable, it
+ * is also recommended to discard already deleted records while rewriting data files. However, the
+ * set of live data records must never change.
+ *
+ * @param dataFile a rewritten data file
+ * @return this for method chaining
+ */
+ default RewriteFiles deleteFile(DataFile dataFile) {
+ throw new UnsupportedOperationException(
+ this.getClass().getName() + " does not implement deleteFile");
+ }
+
+ /**
+ * Remove a delete file from the table state.
+ *
+ * This rewrite operation may change the size or layout of the delete files. When applicable,
+ * it is also recommended to discard delete records for files that are no longer part of the table
+ * state. However, the set of applicable delete records must never change.
+ *
+ * @param deleteFile a rewritten delete file
+ * @return this for method chaining
+ */
+ default RewriteFiles deleteFile(DeleteFile deleteFile) {
+ throw new UnsupportedOperationException(
+ this.getClass().getName() + " does not implement deleteFile");
+ }
+
+ /**
+ * Add a new data file.
+ *
+ * This rewrite operation may change the size or layout of the data files. When applicable, it
+ * is also recommended to discard already deleted records while rewriting data files. However, the
+ * set of live data records must never change.
+ *
+ * @param dataFile a new data file
+ * @return this for method chaining
+ */
+ default RewriteFiles addFile(DataFile dataFile) {
+ throw new UnsupportedOperationException(
+ this.getClass().getName() + " does not implement addFile");
+ }
+
+ /**
+ * Add a new delete file.
+ *
+ * This rewrite operation may change the size or layout of the delete files. When applicable,
+ * it is also recommended to discard delete records for files that are no longer part of the table
+ * state. However, the set of applicable delete records must never change.
+ *
+ * @param deleteFile a new delete file
+ * @return this for method chaining
+ */
+ default RewriteFiles addFile(DeleteFile deleteFile) {
+ throw new UnsupportedOperationException(
+ this.getClass().getName() + " does not implement addFile");
+ }
+
+ /**
+ * Configure the data sequence number for this rewrite operation. This data sequence number will
+ * be used for all new data files that are added in this rewrite. This method is helpful to avoid
+ * commit conflicts between data compaction and adding equality deletes.
+ *
+ * @param sequenceNumber a data sequence number
+ * @return this for method chaining
+ */
+ default RewriteFiles dataSequenceNumber(long sequenceNumber) {
+ throw new UnsupportedOperationException(
+ this.getClass().getName() + " does not implement dataSequenceNumber");
+ }
+
/**
* Add a rewrite that replaces one set of data files with another set that contains the same data.
*
* @param filesToDelete files that will be replaced (deleted), cannot be null or empty.
* @param filesToAdd files that will be added, cannot be null or empty.
* @return this for method chaining
+ * @deprecated since 1.3.0, will be removed in 2.0.0
*/
+ @Deprecated
default RewriteFiles rewriteFiles(Set