-
Notifications
You must be signed in to change notification settings - Fork 3k
Add SnapshotUpdateValidator to validate snapshots on commit #14509
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
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,54 @@ | ||
| /* | ||
| * 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 java.util.function.Function; | ||
| import javax.annotation.Nonnull; | ||
|
|
||
| /** | ||
| * Interface to support validating snapshot ancestry during the commit process. | ||
| * | ||
| * <p>Validation will be called after the table metadata is refreshed to pick up any changes to the | ||
| * table state. | ||
| */ | ||
| @FunctionalInterface | ||
| public interface SnapshotAncestryValidator extends Function<Iterable<Snapshot>, Boolean> { | ||
|
|
||
| SnapshotAncestryValidator NON_VALIDATING = baseSnapshots -> true; | ||
|
|
||
| /** | ||
| * Validate the snapshots based on the refreshed table state. | ||
| * | ||
| * @param baseSnapshots ancestry of the base table metadata snapshots | ||
| * @return boolean for whether the update is valid | ||
| */ | ||
| @Override | ||
| Boolean apply(Iterable<Snapshot> baseSnapshots); | ||
|
Contributor
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. There's no need to pass the full
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. Unfortunately, I don't think what you have in #14515 is quite correct. There's no guarantee (and it's very commonly not the case) that the offsets will be in the prior commit.
Contributor
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.
#14515 checks all new commits when configured with the starting snapshot id.
Contributor
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. I double-checked the implementation of
Contributor
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. nit: wonder if just the primitive type |
||
|
|
||
| /** | ||
| * Validation message that will be included when throwing {@link | ||
| * org.apache.iceberg.exceptions.ValidationException} | ||
| * | ||
| * @return message | ||
| */ | ||
| @Nonnull | ||
| default String errorMessage() { | ||
| return "error message not provided"; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor/optional : This won't be called per commit process ? as not all updates produce a new snapshot, do we wanna say
commits that produce snapshots?