-
Notifications
You must be signed in to change notification settings - Fork 3k
Cherrypick snapshot feature #695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
15b9708
768e051
0c91972
fc46ae4
f73bd0d
d417ef5
aea0746
75ba9c5
7e96144
0befad4
1de9863
0a7a04c
c7f292b
c73119f
5a7d059
ecc6f44
2fb7333
5aceeb4
2a97572
8facf5a
4a4ab93
ecef2cc
4b07bc0
799e1cc
2e2ed7a
e037ecb
1ae0698
50ec210
d123d1a
becef88
25db12a
225374c
78c8a91
98816e5
6e11c4f
ea79707
0a305c4
66363bb
cc020ca
6ca3a63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * 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 org.apache.iceberg.exceptions.CommitFailedException; | ||
| import org.apache.iceberg.exceptions.DuplicateWAPCommitException; | ||
| import org.apache.iceberg.exceptions.ValidationException; | ||
|
|
||
| /** | ||
| * API for managing snapshots. Allows rolling table data back to a stated at an older table {@link Snapshot snapshot}. | ||
| * Rollback: | ||
| * <p> | ||
| * This API does not allow conflicting calls to {@link #setCurrentSnapshot(long)} and | ||
| * {@link #rollbackToTime(long)}. | ||
| * <p> | ||
| * When committing, these changes will be applied to the current table metadata. Commit conflicts | ||
| * will not be resolved and will result in a {@link CommitFailedException}. | ||
| * Cherrypick: | ||
| * <p> | ||
| * In an audit workflow, new data is written to an orphan {@link Snapshot 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. | ||
| * <p> | ||
| */ | ||
| public interface ManageSnapshots extends PendingUpdate<Snapshot> { | ||
|
|
||
| /** | ||
| * Roll this table's data back to a specific {@link Snapshot} identified by id. | ||
| * | ||
| * @param snapshotId long id of the snapshot to roll back table data to | ||
| * @return this for method chaining | ||
| * @throws IllegalArgumentException If the table has no snapshot with the given id | ||
| */ | ||
| ManageSnapshots setCurrentSnapshot(long snapshotId); | ||
|
|
||
| /** | ||
| * Roll this table's data back to the last {@link Snapshot} before the given timestamp. | ||
| * | ||
| * @param timestampMillis a long timestamp, as returned by {@link System#currentTimeMillis()} | ||
| * @return this for method chaining | ||
| * @throws IllegalArgumentException If the table has no old snapshot before the given timestamp | ||
| */ | ||
| ManageSnapshots rollbackToTime(long timestampMillis); | ||
|
|
||
| /** | ||
| * Rollback table's state to a specific {@link Snapshot} identified by id. | ||
| * @param snapshotId long id of snapshot id to roll back table to. Must be an ancestor of the current snapshot | ||
| * @throws IllegalArgumentException If the table has no snapshot with the given id | ||
| * @throws ValidationException If given snapshot id is not an ancestor of the current state | ||
| */ | ||
| ManageSnapshots rollbackTo(long snapshotId); | ||
|
|
||
| /** | ||
| * Apply supported changes in given snapshot and create a new snapshot which will be set as the | ||
| * current snapshot on commit. | ||
| * @param snapshotId a snapshotId whose changes to apply | ||
| * @return this for method chaining | ||
| * @throws IllegalArgumentException If the table has no snapshot with the given id | ||
| * @throws DuplicateWAPCommitException In case of a WAP workflow and if the table has has a duplicate commit with same | ||
| * wapId | ||
| */ | ||
| ManageSnapshots cherrypick(long snapshotId); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * 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.exceptions; | ||
|
|
||
| /** | ||
| * This exception occurs when one cherrypicks an ancestor or when the picked snapshot is already linked to | ||
| * a published ancestor. This additionally helps avoid duplicate cherrypicks on non-WAP snapshots. | ||
| */ | ||
| public class CherrypickAncestorCommitException extends ValidationException { | ||
|
|
||
| public CherrypickAncestorCommitException(long snapshotId) { | ||
| super("Cannot cherrypick snapshot %s: already an ancestor", String.valueOf(snapshotId)); | ||
| } | ||
|
|
||
| public CherrypickAncestorCommitException(long snapshotId, long publishedAncestorId) { | ||
| super("Cannot cherrypick snapshot %s: already picked to create ancestor %s", | ||
| String.valueOf(snapshotId), String.valueOf(publishedAncestorId)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * 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.exceptions; | ||
|
|
||
| /** | ||
| * This exception occurs when the WAP workflow detects a duplicate wap commit. This helps clients | ||
| * to detect duplicate snapshots that are connected by the same wap id. | ||
| */ | ||
| public class DuplicateWAPCommitException extends ValidationException { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This exception helps with making WAP workflow idempotent. We use this exception on the DataFrameWriter to differentiate from a generic validation error so that we can NOOP and report success if the wap id was already committed. I added this so that the caller doesn't have to depend on the error message rather can catch a specific exception. |
||
|
|
||
| public DuplicateWAPCommitException(String wapId) { | ||
| super("Duplicate request to cherry pick wap id that was published already: %s", wapId); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.