Skip to content

Commit

Permalink
fix: define snapshot trait outside of arrow module
Browse files Browse the repository at this point in the history
  • Loading branch information
roeap committed Nov 11, 2023
1 parent fd35b8a commit 05cad10
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
22 changes: 1 addition & 21 deletions crates/deltalake-core/src/kernel/arrow/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,11 @@ use std::task::{ready, Poll};
use super::checkpoint::{parse_action, parse_actions};
use super::schemas::get_log_schema;
use crate::kernel::error::{DeltaResult, Error};
use crate::kernel::snapshot::Snapshot;
use crate::kernel::{Action, ActionType, Add, Metadata, Protocol, StructType};
use crate::storage::path::{commit_version, is_checkpoint_file, is_commit_file, FileMeta, LogPath};
use crate::table::config::TableConfig;

/// A snapshot of a Delta table at a given version.
pub trait Snapshot: std::fmt::Display + Send + Sync + std::fmt::Debug + 'static {
/// The version of the table at this [`Snapshot`].
fn version(&self) -> i64;

/// Table [`Schema`](crate::kernel::schema::StructType) at this [`Snapshot`]'s version.
fn schema(&self) -> Option<&StructType>;

/// Table [`Metadata`] at this [`Snapshot`]'s version.
fn metadata(&self) -> DeltaResult<Metadata>;

/// Table [`Protocol`] at this [`Snapshot`]'s version.
fn protocol(&self) -> DeltaResult<Protocol>;

/// Iterator over the [`Add`] actions at this [`Snapshot`]'s version.
fn files(&self) -> DeltaResult<Box<dyn Iterator<Item = Add> + '_>>;

/// Well known table [configuration](crate::table::config::TableConfig).
fn table_config(&self) -> TableConfig<'_>;
}

/// A [`Snapshot`] that is dynamically typed.
pub type DynSnapshot = dyn Snapshot;

Expand Down
1 change: 1 addition & 0 deletions crates/deltalake-core/src/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod client;
pub mod error;
pub mod expressions;
pub mod schema;
pub mod snapshot;

pub use actions::*;
pub use error::*;
Expand Down
26 changes: 26 additions & 0 deletions crates/deltalake-core/src/kernel/snapshot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! Snapshot of a Delta table.
use crate::kernel::error::DeltaResult;
use crate::kernel::{Add, Metadata, Protocol, StructType};
use crate::table::config::TableConfig;

/// A snapshot of a Delta table at a given version.
pub trait Snapshot: std::fmt::Display + Send + Sync + std::fmt::Debug + 'static {
/// The version of the table at this [`Snapshot`].
fn version(&self) -> i64;

/// Table [`Schema`](crate::kernel::schema::StructType) at this [`Snapshot`]'s version.
fn schema(&self) -> Option<&StructType>;

/// Table [`Metadata`] at this [`Snapshot`]'s version.
fn metadata(&self) -> DeltaResult<Metadata>;

/// Table [`Protocol`] at this [`Snapshot`]'s version.
fn protocol(&self) -> DeltaResult<Protocol>;

/// Iterator over the [`Add`] actions at this [`Snapshot`]'s version.
fn files(&self) -> DeltaResult<Box<dyn Iterator<Item = Add> + '_>>;

/// Well known table [configuration](crate::table::config::TableConfig).
fn table_config(&self) -> TableConfig<'_>;
}
2 changes: 1 addition & 1 deletion crates/deltalake-core/src/table/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use serde::{Deserialize, Serialize};

use super::config::TableConfig;
use crate::errors::DeltaTableError;
use crate::kernel::arrow::snapshot::Snapshot;
use crate::kernel::error::DeltaResult;
use crate::kernel::snapshot::Snapshot;
use crate::kernel::{
Action, Add, CommitInfo, DataType, DomainMetadata, ReaderFeatures, Remove, StructType,
WriterFeatures,
Expand Down

0 comments on commit 05cad10

Please sign in to comment.