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

feat(rust, python): add drop constraint operation #2071

Merged
merged 20 commits into from
Feb 27, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
simplify code
  • Loading branch information
ion-elgreco committed Feb 5, 2024
commit 28d475c89c0df420e34db42be9197b0d23b63583
28 changes: 12 additions & 16 deletions crates/core/src/operations/drop_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,22 @@ impl std::future::IntoFuture for DropConstraintBuilder {
let mut this = self;

Box::pin(async move {
let name = this.name.ok_or(Err(DeltaTableError::Generic("No name provided".to_string())))?;
let name = this
.name
.ok_or(DeltaTableError::Generic("No name provided".to_string()))?;

let mut metadata = this.snapshot.metadata().clone();
let configuration_key = format!("delta.constraints.{}", name);

if metadata.configuration.remove(&configuration_key).is_none() {
if this.raise_if_not_exists {
return Err(DeltaTableError::Generic(format!(
"Constraint with name: {} doesn't exists",
name
)));
}
return Ok(DeltaTable::new_with_state(this.log_store, this.snapshot));
}

let contains_constraints = metadata
.configuration
.keys()
.any(|k| k.starts_with("delta.constraints"));

if metadata.configuration.remove(&configuration_key).is_none() {
if this.raise_if_not_exists {
return Err(DeltaTableError::Generic(format!(
"Constraint with name: {} doesn't exists",
name
)));
}
return Ok(DeltaTable::new_with_state(this.log_store, this.snapshot));
}
let operational_parameters = HashMap::from_iter([("name".to_string(), json!(&name))]);

let operations = DeltaOperation::DropConstraint { name: name.clone() };
Expand Down
Loading