From f1c28d4eb7191dfaab21048791d1a8178875b783 Mon Sep 17 00:00:00 2001 From: Robert Pack Date: Mon, 1 May 2023 12:25:10 +0200 Subject: [PATCH] chore: add deprecation notices for commit logic on DeltaTable --- rust/src/delta.rs | 31 ++++++++++++++++++++++++++++++- rust/src/writer/mod.rs | 1 + rust/src/writer/test_utils.rs | 1 + rust/tests/fs_common/mod.rs | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/rust/src/delta.rs b/rust/src/delta.rs index b7d6cb66aa..a8ea919fe1 100644 --- a/rust/src/delta.rs +++ b/rust/src/delta.rs @@ -1112,6 +1112,10 @@ impl DeltaTable { } /// Vacuum the delta table. See [`VacuumBuilder`] for more information. + #[deprecated( + since = "0.10.0", + note = "use DelaOps from operations module to create a Vacuum operation." + )] pub async fn vacuum( &mut self, retention_hours: Option, @@ -1133,6 +1137,11 @@ impl DeltaTable { /// Creates a new DeltaTransaction for the DeltaTable. /// The transaction holds a mutable reference to the DeltaTable, preventing other references /// until the transaction is dropped. + #[deprecated( + since = "0.10.0", + note = "use 'commit' function from operations module to commit to Delta table." + )] + #[allow(deprecated)] pub fn create_transaction( &mut self, options: Option, @@ -1145,6 +1154,11 @@ impl DeltaTable { /// This is low-level transaction API. If user does not want to maintain the commit loop then /// the `DeltaTransaction.commit` is desired to be used as it handles `try_commit_transaction` /// with retry logic. + #[deprecated( + since = "0.10.0", + note = "use 'commit' function from operations module to commite to Delta table." + )] + #[allow(deprecated)] pub async fn try_commit_transaction( &mut self, commit: &PreparedCommit, @@ -1168,6 +1182,11 @@ impl DeltaTable { } /// Create a DeltaTable with version 0 given the provided MetaData, Protocol, and CommitInfo + #[deprecated( + since = "0.10.0", + note = "use DelaOps from operations module to create a Create operation." + )] + #[allow(deprecated)] pub async fn create( &mut self, metadata: DeltaTableMetaData, @@ -1322,12 +1341,17 @@ impl Default for DeltaTransactionOptions { /// Please not that in case of non-retryable error the temporary commit file such as /// `_delta_log/_commit_.json` will orphaned in storage. #[derive(Debug)] +#[deprecated( + since = "0.10.0", + note = "use 'commit' function from operations module to commit to Delta table." +)] pub struct DeltaTransaction<'a> { delta_table: &'a mut DeltaTable, actions: Vec, options: DeltaTransactionOptions, } +#[allow(deprecated)] impl<'a> DeltaTransaction<'a> { /// Creates a new delta transaction. /// Holds a mutable reference to the delta table to prevent outside mutation while a transaction commit is in progress. @@ -1377,7 +1401,6 @@ impl<'a> DeltaTransaction<'a> { // } else { // IsolationLevel::Serializable // }; - let prepared_commit = self.prepare_commit(operation, app_metadata).await?; // try to commit in a loop in case other writers write the next version first @@ -1430,6 +1453,7 @@ impl<'a> DeltaTransaction<'a> { Ok(PreparedCommit { uri: path }) } + #[allow(deprecated)] async fn try_commit_loop( &mut self, commit: &PreparedCommit, @@ -1473,6 +1497,10 @@ impl<'a> DeltaTransaction<'a> { /// Holds the uri to prepared commit temporary file created with `DeltaTransaction.prepare_commit`. /// Once created, the actual commit could be executed with `DeltaTransaction.try_commit`. #[derive(Debug)] +#[deprecated( + since = "0.10.0", + note = "use 'commit' function from operations module to commit to Delta table." +)] pub struct PreparedCommit { uri: Path, } @@ -1624,6 +1652,7 @@ mod tests { serde_json::Value::String("test user".to_string()), ); // Action + #[allow(deprecated)] dt.create(delta_md.clone(), protocol.clone(), Some(commit_info), None) .await .unwrap(); diff --git a/rust/src/writer/mod.rs b/rust/src/writer/mod.rs index b590a6444e..3c3c40d0aa 100644 --- a/rust/src/writer/mod.rs +++ b/rust/src/writer/mod.rs @@ -128,6 +128,7 @@ pub trait DeltaWriter { table: &mut DeltaTable, ) -> Result { let mut adds = self.flush().await?; + #[allow(deprecated)] let mut tx = table.create_transaction(None); tx.add_actions(adds.drain(..).map(Action::add).collect()); let version = tx.commit(None, None).await?; diff --git a/rust/src/writer/test_utils.rs b/rust/src/writer/test_utils.rs index 62684c3f05..2cb66ac893 100644 --- a/rust/src/writer/test_utils.rs +++ b/rust/src/writer/test_utils.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] //! Utilities for writing unit tests use super::*; use crate::{ diff --git a/rust/tests/fs_common/mod.rs b/rust/tests/fs_common/mod.rs index 7d1383afd9..4243afbe98 100644 --- a/rust/tests/fs_common/mod.rs +++ b/rust/tests/fs_common/mod.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] use chrono::Utc; use deltalake::action::{Action, Add, Protocol, Remove}; use deltalake::{