Skip to content

Commit

Permalink
remove protocol downgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-elgreco committed Feb 1, 2024
1 parent 1b12b55 commit ea9546a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
29 changes: 2 additions & 27 deletions crates/core/src/operations/drop_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use chrono::Utc;
use futures::future::BoxFuture;
use serde_json::json;

use crate::kernel::{Action, CommitInfo, IsolationLevel, Protocol};
use crate::kernel::{Action, CommitInfo, IsolationLevel};
use crate::logstore::LogStoreRef;
use crate::operations::transaction::commit;
use crate::protocol::DeltaOperation;
Expand Down Expand Up @@ -115,32 +115,7 @@ impl std::future::IntoFuture for DropConstraintBuilder {
..Default::default()
};

let protocol = if !contains_constraints {
// downgrade the protocol if possible since there are no more constraints
let old_protocol = this.snapshot.protocol();
Some(Protocol {
min_reader_version: if old_protocol.min_reader_version > 1 {
old_protocol.min_reader_version
} else {
1
},
min_writer_version: if old_protocol.min_writer_version > 3 {
old_protocol.min_writer_version
} else {
2
},
reader_features: old_protocol.reader_features.clone(),
writer_features: old_protocol.writer_features.clone(),
})
} else {
None
};

let mut actions = vec![Action::CommitInfo(commit_info), Action::Metadata(metadata)];

if let Some(protocol) = protocol {
actions.push(Action::Protocol(protocol))
};
let actions = vec![Action::CommitInfo(commit_info), Action::Metadata(metadata)];

let version = commit(
this.log_store.as_ref(),
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_alter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_drop_constraint(tmp_path: pathlib.Path, sample_table: pa.Table):
assert last_action["operation"] == "DROP CONSTRAINT"
assert dt.version() == 2
assert dt.metadata().configuration == {}
assert dt.protocol().min_writer_version == 2
assert dt.protocol().min_writer_version == 3


def test_drop_constraint_invalid(tmp_path: pathlib.Path, sample_table: pa.Table):
Expand Down

0 comments on commit ea9546a

Please sign in to comment.