From 43afea1a9d8392de8d0b361a0427879739933744 Mon Sep 17 00:00:00 2001 From: Jeremyhi Date: Fri, 31 May 2024 14:41:53 +0800 Subject: [PATCH] refactor!: remove the tableid in ddl response since tableids is enough (#4080) * refactor: remove the tableid in ddl response since tableids is enough * chore: upgrade proto --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/common/meta/src/ddl_manager.rs | 7 ++----- src/common/meta/src/rpc/ddl.rs | 10 +--------- src/operator/src/statement/ddl.rs | 20 ++++++++++++++------ 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4af34e8623bb..007f77744138 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4188,7 +4188,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "greptime-proto" version = "0.1.0" -source = "git+https://github.com/killme2008/greptime-proto.git?rev=a15a54a714fe117d7e9f7635e149c4eecac773fa#a15a54a714fe117d7e9f7635e149c4eecac773fa" +source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=ae26136accd82fbdf8be540cd502f2e94951077e#ae26136accd82fbdf8be540cd502f2e94951077e" dependencies = [ "prost 0.12.4", "serde", diff --git a/Cargo.toml b/Cargo.toml index 7d03eb0f4387..734d2438b0b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -120,7 +120,7 @@ etcd-client = { git = "https://github.com/MichaelScofield/etcd-client.git", rev fst = "0.4.7" futures = "0.3" futures-util = "0.3" -greptime-proto = { git = "https://github.com/killme2008/greptime-proto.git", rev = "a15a54a714fe117d7e9f7635e149c4eecac773fa" } +greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "ae26136accd82fbdf8be540cd502f2e94951077e" } humantime = "2.1" humantime-serde = "1.1" itertools = "0.10" diff --git a/src/common/meta/src/ddl_manager.rs b/src/common/meta/src/ddl_manager.rs index 03cd00d13f5c..ba6199c73854 100644 --- a/src/common/meta/src/ddl_manager.rs +++ b/src/common/meta/src/ddl_manager.rs @@ -489,8 +489,7 @@ async fn handle_create_table_task( Ok(SubmitDdlTaskResponse { key: procedure_id.into(), - table_id: Some(table_id), - ..Default::default() + table_ids: vec![table_id], }) } @@ -534,7 +533,6 @@ async fn handle_create_logical_table_tasks( Ok(SubmitDdlTaskResponse { key: procedure_id.into(), table_ids, - ..Default::default() }) } @@ -690,8 +688,7 @@ async fn handle_create_view_task( Ok(SubmitDdlTaskResponse { key: procedure_id.into(), - table_id: Some(view_id), - ..Default::default() + table_ids: vec![view_id], }) } diff --git a/src/common/meta/src/rpc/ddl.rs b/src/common/meta/src/rpc/ddl.rs index e6140cdaeff7..0389be97083e 100644 --- a/src/common/meta/src/rpc/ddl.rs +++ b/src/common/meta/src/rpc/ddl.rs @@ -274,10 +274,7 @@ impl TryFrom for PbDdlTaskRequest { #[derive(Debug, Default)] pub struct SubmitDdlTaskResponse { pub key: Vec, - // For create physical table - // TODO(jeremy): remove it? - pub table_id: Option, - // For create multi logical tables + // `table_id`s for `CREATE TABLE` or `CREATE LOGICAL TABLES` task. pub table_ids: Vec, } @@ -285,11 +282,9 @@ impl TryFrom for SubmitDdlTaskResponse { type Error = error::Error; fn try_from(resp: PbDdlTaskResponse) -> Result { - let table_id = resp.table_id.map(|t| t.id); let table_ids = resp.table_ids.into_iter().map(|t| t.id).collect(); Ok(Self { key: resp.pid.map(|pid| pid.key).unwrap_or_default(), - table_id, table_ids, }) } @@ -299,9 +294,6 @@ impl From for PbDdlTaskResponse { fn from(val: SubmitDdlTaskResponse) -> Self { Self { pid: Some(ProcedureId { key: val.key }), - table_id: val - .table_id - .map(|table_id| api::v1::TableId { id: table_id }), table_ids: val .table_ids .into_iter() diff --git a/src/operator/src/statement/ddl.rs b/src/operator/src/statement/ddl.rs index 2cfe71fd0d24..2cce8f38d727 100644 --- a/src/operator/src/statement/ddl.rs +++ b/src/operator/src/statement/ddl.rs @@ -238,9 +238,13 @@ impl StatementExecutor { ) .await?; - let table_id = resp.table_id.context(error::UnexpectedSnafu { - violated: "expected table_id", - })?; + let table_id = resp + .table_ids + .into_iter() + .next() + .context(error::UnexpectedSnafu { + violated: "expected table_id", + })?; info!("Successfully created table '{table_name}' with table id {table_id}"); table_info.ident.table_id = table_id; @@ -531,9 +535,13 @@ impl StatementExecutor { resp ); - let view_id = resp.table_id.context(error::UnexpectedSnafu { - violated: "expected table_id", - })?; + let view_id = resp + .table_ids + .into_iter() + .next() + .context(error::UnexpectedSnafu { + violated: "expected table_id", + })?; info!("Successfully created view '{view_name}' with view id {view_id}"); // Invalidates local cache ASAP.