CTTY commented on code in PR #2590:
URL: https://github.com/apache/iceberg-rust/pull/2590#discussion_r3359656353


##########
crates/iceberg/src/transaction/validate.rs:
##########
@@ -0,0 +1,261 @@
+// 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.
+
+use std::collections::HashSet;
+
+use futures::SinkExt;
+use futures::future::try_join_all;
+use once_cell::sync::Lazy;
+
+use crate::delete_file_index::DeleteFileIndex;
+use crate::error::Result;
+use crate::scan::DeleteFileContext;
+use crate::spec::{
+    DataContentType, DataFile, FormatVersion, INITIAL_SEQUENCE_NUMBER, 
ManifestContentType,
+    ManifestFile, Operation,
+};
+use crate::table::Table;
+use crate::util::snapshot::ancestors_between;
+use crate::{Error, ErrorKind};
+
+/// Operations whose snapshots may add delete files.
+static VALIDATE_ADDED_DELETE_FILES_OPERATIONS: Lazy<HashSet<Operation>> =
+    Lazy::new(|| HashSet::from([Operation::Overwrite, Operation::Delete]));
+
+/// A trait for validating a snapshot before it is committed.
+///
+/// Each 
[`SnapshotProduceOperation`](super::snapshot::SnapshotProduceOperation) is also 
a
+/// `SnapshotValidator`. The [`validate`](SnapshotValidator::validate) method 
is invoked by
+/// [`SnapshotProducer::commit`](super::snapshot::SnapshotProducer) before the 
new snapshot is
+/// written, giving each operation the chance to detect conflicts against the 
(refreshed) base
+/// table. Operations that need no validation (e.g. fast append) rely on the 
default no-op
+/// implementation.
+///
+/// The reusable checks 
([`validation_history`](SnapshotValidator::validation_history),
+/// 
[`validate_no_new_deletes_for_data_files`](SnapshotValidator::validate_no_new_deletes_for_data_files))
+/// are provided as default methods so concrete operations can compose the 
subset they require.
+pub(crate) trait SnapshotValidator {
+    /// Validates a snapshot against a table.
+    ///
+    /// # Arguments
+    ///
+    /// * `base` - The base table to validate against.
+    /// * `parent_snapshot_id` - The ID of the parent snapshot, if any. This 
is usually
+    ///   the latest snapshot of the base table, unless it's a non-main branch
+    ///   (note: writing to branches is not currently supported).
+    ///
+    /// # Returns
+    ///
+    /// A `Result` indicating success or an error if validation fails.
+    async fn validate(&self, _base: &Table, _parent_snapshot_id: Option<i64>) 
-> Result<()> {
+        Ok(())
+    }
+
+    /// Retrieves the history of snapshots between two points with matching 
operations and content
+    /// type.
+    ///
+    /// # Arguments
+    ///
+    /// * `base` - The base table to retrieve history from.
+    /// * `from_snapshot_id` - The starting snapshot ID (exclusive), or None 
to start from the
+    ///   beginning.
+    /// * `to_snapshot_id` - The ending snapshot ID (inclusive).
+    /// * `matching_operations` - Set of operations to match when collecting 
snapshots.
+    /// * `manifest_content_type` - The content type of manifests to collect.
+    ///
+    /// # Returns
+    ///
+    /// A tuple containing:
+    /// * A vector of manifest files matching the criteria.
+    /// * A set of snapshot IDs that were collected.
+    ///
+    /// # Errors
+    ///
+    /// Returns an error if the history between the snapshots cannot be 
determined.
+    #[allow(dead_code)]

Review Comment:
   marking them as dead_code for now and they will be used by delete or rewrite 
actions later on



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