Skip to content

Commit

Permalink
chore: get_sequence() just use the name_ident
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Sep 18, 2024
1 parent 8a7d25d commit 678d57e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
27 changes: 8 additions & 19 deletions src/meta/api/src/schema_api_test_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ use databend_common_meta_app::schema::ExtendLockRevReq;
use databend_common_meta_app::schema::GcDroppedTableReq;
use databend_common_meta_app::schema::GetDatabaseReq;
use databend_common_meta_app::schema::GetSequenceNextValueReq;
use databend_common_meta_app::schema::GetSequenceReq;
use databend_common_meta_app::schema::GetTableCopiedFileReq;
use databend_common_meta_app::schema::GetTableReq;
use databend_common_meta_app::schema::IcebergCatalogOption;
Expand Down Expand Up @@ -5598,10 +5597,8 @@ impl SchemaApiTestSuite {

info!("--- get sequence");
{
let req = GetSequenceReq {
ident: SequenceIdent::new(&tenant, sequence_name),
};
let resp = mt.get_sequence(req).await?;
let req = SequenceIdent::new(&tenant, sequence_name);
let resp = mt.get_sequence(&req).await?;
let resp = resp.unwrap().data;
assert_eq!(resp.comment, Some("seq".to_string()));
assert_eq!(resp.current, 1);
Expand All @@ -5620,11 +5617,8 @@ impl SchemaApiTestSuite {

info!("--- get sequence after nextval");
{
let req = GetSequenceReq {
ident: SequenceIdent::new(&tenant, sequence_name),
};

let resp = mt.get_sequence(req).await?;
let req = SequenceIdent::new(&tenant, sequence_name);
let resp = mt.get_sequence(&req).await?;
let resp = resp.unwrap().data;
assert_eq!(resp.comment, Some("seq".to_string()));
assert_eq!(resp.current, 11);
Expand All @@ -5641,11 +5635,9 @@ impl SchemaApiTestSuite {

let _resp = mt.create_sequence(req).await?;

let req = GetSequenceReq {
ident: SequenceIdent::new(&tenant, sequence_name),
};
let req = SequenceIdent::new(&tenant, sequence_name);

let resp = mt.get_sequence(req).await?;
let resp = mt.get_sequence(&req).await?;
let resp = resp.unwrap().data;
assert_eq!(resp.comment, Some("seq1".to_string()));
assert_eq!(resp.current, 1);
Expand All @@ -5659,11 +5651,8 @@ impl SchemaApiTestSuite {

let _resp = mt.drop_sequence(req).await?;

let req = GetSequenceReq {
ident: SequenceIdent::new(&tenant, sequence_name),
};

let resp = mt.get_sequence(req).await?;
let req = SequenceIdent::new(&tenant, sequence_name);
let resp = mt.get_sequence(&req).await?;
assert!(resp.is_none());
}

Expand Down
4 changes: 2 additions & 2 deletions src/meta/api/src/sequence_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use databend_common_meta_app::schema::DropSequenceReply;
use databend_common_meta_app::schema::DropSequenceReq;
use databend_common_meta_app::schema::GetSequenceNextValueReply;
use databend_common_meta_app::schema::GetSequenceNextValueReq;
use databend_common_meta_app::schema::GetSequenceReq;
use databend_common_meta_app::schema::SequenceIdent;
use databend_common_meta_app::schema::SequenceMeta;
use databend_common_meta_types::MetaError;
use databend_common_meta_types::SeqV;
Expand All @@ -34,7 +34,7 @@ pub trait SequenceApi: Send + Sync {

async fn get_sequence(
&self,
req: GetSequenceReq,
req: &SequenceIdent,
) -> Result<Option<SeqV<SequenceMeta>>, MetaError>;

async fn get_sequence_next_value(
Expand Down
8 changes: 4 additions & 4 deletions src/meta/api/src/sequence_api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use databend_common_meta_app::schema::DropSequenceReply;
use databend_common_meta_app::schema::DropSequenceReq;
use databend_common_meta_app::schema::GetSequenceNextValueReply;
use databend_common_meta_app::schema::GetSequenceNextValueReq;
use databend_common_meta_app::schema::GetSequenceReq;
use databend_common_meta_app::schema::SequenceIdent;
use databend_common_meta_app::schema::SequenceMeta;
use databend_common_meta_kvapi::kvapi;
use databend_common_meta_types::MatchSeq;
Expand Down Expand Up @@ -85,10 +85,10 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?Sized> SequenceApi for KV {

async fn get_sequence(
&self,
req: GetSequenceReq,
name_ident: &SequenceIdent,
) -> Result<Option<SeqV<SequenceMeta>>, MetaError> {
debug!(req :? =(&req); "SchemaApi: {}", func_name!());
let seq_meta = self.get_pb(&req.ident).await?;
debug!(req :? =name_ident; "SchemaApi: {}", func_name!());
let seq_meta = self.get_pb(name_ident).await?;
Ok(seq_meta)
}

Expand Down
2 changes: 1 addition & 1 deletion src/query/service/src/catalogs/default/mutable_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ impl Catalog for MutableCatalog {
}

async fn get_sequence(&self, req: GetSequenceReq) -> Result<GetSequenceReply> {
let seq_meta = self.ctx.meta.get_sequence(req).await?;
let seq_meta = self.ctx.meta.get_sequence(&req.ident).await?;

let Some(seq_meta) = seq_meta else {
return Err(KVAppError::AppError(AppError::SequenceError(
Expand Down

0 comments on commit 678d57e

Please sign in to comment.