Skip to content
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

chore: introduce the Operation trait to enforce consistency between operations #2435

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/core/src/operations/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub struct ConstraintBuilder {
commit_properties: CommitProperties,
}

impl super::Operation<()> for ConstraintBuilder {}

impl ConstraintBuilder {
/// Create a new builder
pub fn new(log_store: LogStoreRef, snapshot: DeltaTableState) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/convert_to_delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ impl Default for ConvertToDeltaBuilder {
}
}

impl super::Operation<()> for ConvertToDeltaBuilder {}

impl ConvertToDeltaBuilder {
/// Create a new [`ConvertToDeltaBuilder`]
pub fn new() -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ pub struct CreateBuilder {
metadata: Option<HashMap<String, Value>>,
}

impl super::Operation<()> for CreateBuilder {}

impl Default for CreateBuilder {
fn default() -> Self {
Self::new()
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pub struct DeleteMetrics {
pub rewrite_time_ms: u128,
}

impl super::Operation<()> for DeleteBuilder {}

impl DeleteBuilder {
/// Create a new [`DeleteBuilder`]
pub fn new(log_store: LogStoreRef, snapshot: DeltaTableState) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/drop_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub struct DropConstraintBuilder {
commit_properties: CommitProperties,
}

impl super::Operation<()> for DropConstraintBuilder {}

impl DropConstraintBuilder {
/// Create a new builder
pub fn new(log_store: LogStoreRef, snapshot: DeltaTableState) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/filesystem_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ fn is_absolute_path(path: &str) -> DeltaResult<bool> {
}
}

impl super::Operation<()> for FileSystemCheckBuilder {}

impl FileSystemCheckBuilder {
/// Create a new [`FileSystemCheckBuilder`]
pub fn new(log_store: LogStoreRef, state: DeltaTableState) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct LoadBuilder {
columns: Option<Vec<String>>,
}

impl super::Operation<()> for LoadBuilder {}

impl LoadBuilder {
/// Create a new [`LoadBuilder`]
pub fn new(log_store: LogStoreRef, snapshot: DeltaTableState) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/merge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ pub struct MergeBuilder {
safe_cast: bool,
}

impl super::Operation<()> for MergeBuilder {}

impl MergeBuilder {
/// Create a new [`MergeBuilder`]
pub fn new<E: Into<Expression>>(
Expand Down
4 changes: 3 additions & 1 deletion crates/core/src/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ pub mod update;
pub mod write;
pub mod writer;

// TODO make ops consume a snapshot ...
/// The [Operation] trait defines common behaviors that all operations builders
/// should have consistent
pub(crate) trait Operation<State>: std::future::IntoFuture {}

/// High level interface for executing commands against a DeltaTable
pub struct DeltaOps(pub DeltaTable);
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ pub struct OptimizeBuilder<'a> {
min_commit_interval: Option<Duration>,
}

impl super::Operation<()> for OptimizeBuilder<'_> {}

impl<'a> OptimizeBuilder<'a> {
/// Create a new [`OptimizeBuilder`]
pub fn new(log_store: LogStoreRef, snapshot: DeltaTableState) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ pub struct RestoreBuilder {
commit_properties: CommitProperties,
}

impl super::Operation<()> for RestoreBuilder {}

impl RestoreBuilder {
/// Create a new [`RestoreBuilder`]
pub fn new(log_store: LogStoreRef, snapshot: DeltaTableState) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ pub struct UpdateMetrics {
pub scan_time_ms: u64,
}

impl super::Operation<()> for UpdateBuilder {}

impl UpdateBuilder {
/// Create a new ['UpdateBuilder']
pub fn new(log_store: LogStoreRef, snapshot: DeltaTableState) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/vacuum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ pub struct VacuumBuilder {
commit_properties: CommitProperties,
}

impl super::Operation<()> for VacuumBuilder {}

/// Details for the Vacuum operation including which files were
#[derive(Debug)]
pub struct VacuumMetrics {
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/operations/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ pub struct WriteBuilder {
configuration: HashMap<String, Option<String>>,
}

impl super::Operation<()> for WriteBuilder {}

impl WriteBuilder {
/// Create a new [`WriteBuilder`]
pub fn new(log_store: LogStoreRef, snapshot: Option<DeltaTableState>) -> Self {
Expand Down
Loading