From 678d57e994d7c854a0b4a517ecd65bec59e5d99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=82=8E=E6=B3=BC?= Date: Wed, 18 Sep 2024 20:40:00 +0800 Subject: [PATCH] chore: get_sequence() just use the name_ident --- src/meta/api/src/schema_api_test_suite.rs | 27 ++++++------------- src/meta/api/src/sequence_api.rs | 4 +-- src/meta/api/src/sequence_api_impl.rs | 8 +++--- .../src/catalogs/default/mutable_catalog.rs | 2 +- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/meta/api/src/schema_api_test_suite.rs b/src/meta/api/src/schema_api_test_suite.rs index 7730f12f1bd1..ac7fb4e794a3 100644 --- a/src/meta/api/src/schema_api_test_suite.rs +++ b/src/meta/api/src/schema_api_test_suite.rs @@ -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; @@ -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); @@ -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); @@ -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); @@ -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()); } diff --git a/src/meta/api/src/sequence_api.rs b/src/meta/api/src/sequence_api.rs index c16a80775edb..9c48617d062c 100644 --- a/src/meta/api/src/sequence_api.rs +++ b/src/meta/api/src/sequence_api.rs @@ -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; @@ -34,7 +34,7 @@ pub trait SequenceApi: Send + Sync { async fn get_sequence( &self, - req: GetSequenceReq, + req: &SequenceIdent, ) -> Result>, MetaError>; async fn get_sequence_next_value( diff --git a/src/meta/api/src/sequence_api_impl.rs b/src/meta/api/src/sequence_api_impl.rs index 6ff5f982c83c..6183d0cfd5e8 100644 --- a/src/meta/api/src/sequence_api_impl.rs +++ b/src/meta/api/src/sequence_api_impl.rs @@ -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; @@ -85,10 +85,10 @@ impl + ?Sized> SequenceApi for KV { async fn get_sequence( &self, - req: GetSequenceReq, + name_ident: &SequenceIdent, ) -> Result>, 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) } diff --git a/src/query/service/src/catalogs/default/mutable_catalog.rs b/src/query/service/src/catalogs/default/mutable_catalog.rs index 1788293250fd..a0568ab38df3 100644 --- a/src/query/service/src/catalogs/default/mutable_catalog.rs +++ b/src/query/service/src/catalogs/default/mutable_catalog.rs @@ -687,7 +687,7 @@ impl Catalog for MutableCatalog { } async fn get_sequence(&self, req: GetSequenceReq) -> Result { - 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(