Skip to content

Commit 44fd170

Browse files
committed
i like writing doc
1 parent 327401f commit 44fd170

File tree

1 file changed

+52
-7
lines changed

1 file changed

+52
-7
lines changed

crates/iceberg/src/transaction/validate.rs

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,46 @@ use crate::{Error, ErrorKind};
3636
static VALIDATE_ADDED_DELETE_FILES_OPERATIONS: Lazy<HashSet<Operation>> =
3737
Lazy::new(|| HashSet::from([Operation::Overwrite, Operation::Delete]));
3838

39+
/// A trait for validating snapshots in an Iceberg table.
40+
///
41+
/// This trait provides methods to validate snapshots and their history,
42+
/// ensuring data integrity and consistency across table operations.
3943
pub(crate) trait SnapshotValidator {
40-
// todo doc
41-
// table: base table
42-
// snapshot: parent snapshot
43-
// usually snapshot is the latest snapshot of base table, unless it's non-main branch
44-
// but we don't support writing to branches as of now
44+
/// Validates a snapshot against a table.
45+
///
46+
/// # Arguments
47+
///
48+
/// * `base` - The base table to validate against
49+
/// * `parent_snapshot_id` - The ID of the parent snapshot, if any. This is usually
50+
/// the latest snapshot of the base table, unless it's a non-main branch
51+
/// (note: writing to branches is not currently supported)
52+
///
53+
/// # Returns
54+
///
55+
/// A `Result` indicating success or an error if validation fails
4556
async fn validate(&self, _base: &Table, _parent_snapshot_id: Option<i64>) -> Result<()> {
46-
// todo: add default implementation
4757
Ok(())
4858
}
4959

50-
// todo doc
60+
/// Retrieves the history of snapshots between two points with matching operations and content type.
61+
///
62+
/// # Arguments
63+
///
64+
/// * `base` - The base table to retrieve history from
65+
/// * `from_snapshot_id` - The starting snapshot ID (exclusive), or None to start from the beginning
66+
/// * `to_snapshot_id` - The ending snapshot ID (inclusive)
67+
/// * `matching_operations` - Set of operations to match when collecting snapshots
68+
/// * `manifest_content_type` - The content type of manifests to collect
69+
///
70+
/// # Returns
71+
///
72+
/// A tuple containing:
73+
/// * A vector of manifest files matching the criteria
74+
/// * A set of snapshot IDs that were collected
75+
///
76+
/// # Errors
77+
///
78+
/// Returns an error if the history between the snapshots cannot be determined
5179
async fn validation_history(
5280
&self,
5381
base: &Table,
@@ -104,6 +132,23 @@ pub(crate) trait SnapshotValidator {
104132
Ok((manifests, new_snapshots))
105133
}
106134

135+
/// Validates that there are no new delete files for the given data files.
136+
///
137+
/// # Arguments
138+
///
139+
/// * `base` - The base table to validate against
140+
/// * `from_snapshot_id` - The starting snapshot ID (exclusive), or None to start from the beginning
141+
/// * `to_snapshot_id` - The ending snapshot ID (inclusive), or None if there is no current table state
142+
/// * `data_files` - The data files to check for conflicting delete files
143+
/// * `ignore_equality_deletes` - Whether to ignore equality deletes and only check for positional deletes
144+
///
145+
/// # Returns
146+
///
147+
/// A `Result` indicating success or an error if validation fails
148+
///
149+
/// # Errors
150+
///
151+
/// Returns an error if new delete files are found for any of the data files
107152
async fn validate_no_new_delete_files_for_data_files(
108153
&self,
109154
base: &Table,

0 commit comments

Comments
 (0)