Skip to content
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

refactor(frontend): more work-in-progress refactors in create table handler #19941

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions src/frontend/src/handler/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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<String>,
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 {
Expand Down
Loading