From 519cac0eaf4fcbe66bcd9ed8d3dfa995bbb4b564 Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Thu, 26 Dec 2024 14:33:25 +0800 Subject: [PATCH] inline function Signed-off-by: Bugen Zhao --- src/frontend/src/handler/create_table.rs | 44 ++++++++---------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/src/frontend/src/handler/create_table.rs b/src/frontend/src/handler/create_table.rs index a8acbbeb350a..a9a0d3964a3b 100644 --- a/src/frontend/src/handler/create_table.rs +++ b/src/frontend/src/handler/create_table.rs @@ -546,15 +546,22 @@ pub(crate) async fn gen_create_table_plan_with_source( let pb_source = source_catalog.to_prost(schema_id, database_id); - let context = OptimizerContext::new(handler_args, explain_options); + let (plan, table) = { + let context = OptimizerContext::new(handler_args, explain_options).into(); + let version = col_id_gen.into_version(); + let table_name = source_catalog.name.clone(); + + let info = CreateTableInfo { + columns: source_catalog.columns.clone(), + pk_column_ids: source_catalog.pk_col_ids.clone(), + row_id_index: source_catalog.row_id_index, + watermark_descs: source_catalog.watermark_descs.clone(), + source_catalog: Some(source_catalog), + version, + }; - let (plan, table) = gen_table_plan_with_source( - context.into(), - schema_name, - source_catalog, - col_id_gen.into_version(), - props, - )?; + gen_table_plan_inner(context, schema_name, table_name, info, props) + }?; Ok((plan, Some(pb_source), table)) } @@ -636,27 +643,6 @@ pub(crate) fn gen_create_table_plan_without_source( gen_table_plan_inner(context.into(), schema_name, table_name, info, props) } -fn gen_table_plan_with_source( - context: OptimizerContextRef, - schema_name: Option, - source_catalog: SourceCatalog, - version: TableVersion, - props: CreateTableProps, -) -> Result<(PlanRef, PbTable)> { - let table_name = source_catalog.name.clone(); - - let info = CreateTableInfo { - columns: source_catalog.columns.clone(), - pk_column_ids: source_catalog.pk_col_ids.clone(), - row_id_index: source_catalog.row_id_index, - watermark_descs: source_catalog.watermark_descs.clone(), - source_catalog: Some(source_catalog), - version, - }; - - gen_table_plan_inner(context, schema_name, table_name, info, props) -} - /// On-conflict behavior either from user input or existing table catalog. #[derive(Clone, Copy)] pub enum EitherOnConflict {