-
Notifications
You must be signed in to change notification settings - Fork 763
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: add create or replace stage support #14548
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 13 files at r1, all commit messages.
Reviewable status: 2 of 13 files reviewed, 1 unresolved discussion (waiting on @lichuang)
src/query/management/src/stage/stage_mgr.rs
line 107 at r1 (raw file):
&key, serialize_struct(&info, ErrorCode::IllegalUserStageFormat, || "")?, )];
Why is it written as a transaction here? Wouldn't a simple upsert be enough? For CreateIfNotExists, it would be MatchSeq::Exact(0)
; and for CreateOrReplace, it would be MatchSeq::GE(0)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 13 files reviewed, 1 unresolved discussion (waiting on @lichuang)
src/query/management/src/stage/stage_mgr.rs
line 106 at r2 (raw file):
self.kv_api .upsert_kv(UpsertKVReq::new(&key, seq, val, None)) .await?;
The result of the upsert must be checked to see if it succeeded.
And the get()
before upsert
is unnecessary.
Suggestion:
let seq = match create_option {
CreateOption::CreateIfNotExists(_) => MatchSeq::Exact(0),
CreateOption::CreateOrReplace => MatchSeq::GE(0),
};
let res = self.kv_api
.upsert_kv(UpsertKVReq::new(&key, seq, val, None))
.await?;
match create_option {
CreateOption::CreateIfNotExists(false) => {
if res.prev.is_some() {
return Err(ErrorCode::StageAlreadyExists(format!(
"Stage '{}' already exists.",
info.stage_name
)));
}
},
_ => {}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 13 files at r1, 1 of 1 files at r3, all commit messages.
Reviewable status: 10 of 13 files reviewed, all discussions resolved
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
feat: add create or replace stage support
Tests
Type of change
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)