Skip to content

Commit

Permalink
chore: add deprecation notices for commit logic on DeltaTable
Browse files Browse the repository at this point in the history
  • Loading branch information
roeap committed May 1, 2023
1 parent eda7b04 commit f1c28d4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
31 changes: 30 additions & 1 deletion rust/src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
Expand All @@ -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<DeltaTransactionOptions>,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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_<uuid>.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<Action>,
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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1430,6 +1453,7 @@ impl<'a> DeltaTransaction<'a> {
Ok(PreparedCommit { uri: path })
}

#[allow(deprecated)]
async fn try_commit_loop(
&mut self,
commit: &PreparedCommit,
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions rust/src/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub trait DeltaWriter<T> {
table: &mut DeltaTable,
) -> Result<DeltaDataTypeVersion, DeltaTableError> {
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?;
Expand Down
1 change: 1 addition & 0 deletions rust/src/writer/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(deprecated)]
//! Utilities for writing unit tests
use super::*;
use crate::{
Expand Down
1 change: 1 addition & 0 deletions rust/tests/fs_common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(deprecated)]
use chrono::Utc;
use deltalake::action::{Action, Add, Protocol, Remove};
use deltalake::{
Expand Down

0 comments on commit f1c28d4

Please sign in to comment.