rdblue commented on a change in pull request #695: [WIP] Cherrypick snapshot 
feature
URL: https://github.com/apache/incubator-iceberg/pull/695#discussion_r358407620
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/CherryPickFromSnapshot.java
 ##########
 @@ -0,0 +1,225 @@
+/*
+ * 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;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.iceberg.exceptions.CommitFailedException;
+import org.apache.iceberg.exceptions.RuntimeIOException;
+import org.apache.iceberg.exceptions.ValidationException;
+import org.apache.iceberg.io.OutputFile;
+import org.apache.iceberg.util.Tasks;
+import org.apache.iceberg.util.ThreadPools;
+
+/**
+ * In an audit workflow, new data is written to an orphan snapshot that is not 
committed as the table's
+ * current state until it is audited. After auditing a change, it may need to 
be applied or cherry-picked
+ * on top of the latest snapshot instead of the one that was current when the 
audited changes were created.
+ *
+ * This class adds support for cherry-picking the changes from an orphan 
snapshot by applying them to
+ * the current snapshot. The output of the operation is a new snapshot with 
the changes from cherry-picked
+ * snapshot.
+ *
+ * Cherry-picking should apply the exact set of changes that were done in the 
original commit.
+ *  - All added files should be added to the new version.
+ *  - Todo: If files were deleted, then those files must still exist in the 
data set.
+ *  - Does not support Overwrite operations currently. Overwrites are 
considered as conflicts.
 
 Review comment:
   There are a few easy cases to support. First, appends can always be picked 
on top of any version. That's a good one to start with. Next, if the current 
snapshot is the picked commit's parent, then this can commit a "fast-forward" 
change and update just the current snapshot ID.
   
   Overwrites get harder because we have to check history. For a dynamic 
partition overwrite, we need to make sure that no data has been added to any of 
the affected partitions since the commit. For expression overwrites, we need to 
similarly make sure that no new files match the commit's delete expression.
   
   I think we would need extra metadata for overwrites and fast-forwards are a 
slightly different case, so I think it is a good idea to focus on just the 
append case in this PR.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to