Skip to content

Commit

Permalink
improve doc
Browse files Browse the repository at this point in the history
Signed-off-by: xxchan <[email protected]>
  • Loading branch information
xxchan committed Dec 18, 2024
1 parent b3cf119 commit 05a614e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions crates/iceberg/src/metadata_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ use crate::table::Table;
use crate::Result;

/// Table metadata scan.
///
/// Used to inspect a table's history, snapshots, and other metadata as a table.
///
/// See also <https://iceberg.apache.org/docs/latest/spark-queries/#inspecting-tables>.
#[derive(Debug)]
pub struct MetadataScan {
metadata_ref: TableMetadataRef,
Expand All @@ -48,6 +52,10 @@ impl MetadataScan {
}
}

/// Table metadata scan.
///
/// Use to inspect a table's history, snapshots, and other metadata as a table.
///
/// References:
/// - <https://github.com/apache/iceberg/blob/ac865e334e143dfd9e33011d8cf710b46d91f1e5/core/src/main/java/org/apache/iceberg/MetadataTableType.java#L23-L39>
/// - <https://iceberg.apache.org/docs/latest/spark-queries/#querying-with-sql>
Expand All @@ -65,15 +73,6 @@ pub struct SnapshotsTable;

impl MetadataTable for SnapshotsTable {
fn schema() -> Schema {
// committed_at: timestamp[ms] not null
// snapshot_id: int64 not null
// parent_id: int64
// operation: string
// manifest_list: string not null
// summary: map<string, string>
// child 0, entries: struct<key: string not null, value: string> not null
// child 0, key: string not null
// child 1, value: string
Schema::new(vec![
Field::new(
"committed_at",
Expand Down Expand Up @@ -196,8 +195,7 @@ mod tests {
#[test]
fn test_snapshots_table() {
let table = TableTestFixture::new().table;
let scan = MetadataScan::new(&table);
let record_batch = SnapshotsTable::scan(&scan).unwrap();
let record_batch = table.metadata_scan().snapshots();
check_record_batch(
record_batch,
expect![[r#"
Expand Down
2 changes: 1 addition & 1 deletion crates/iceberg/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl Table {
TableScanBuilder::new(self)
}

/// Creates a metadata scan.
/// Creates a metadata scan. See [`MetadataScan`] for more details.
pub fn metadata_scan(&self) -> MetadataScan {
MetadataScan::new(self)
}
Expand Down

0 comments on commit 05a614e

Please sign in to comment.