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

feat(frontend): use purified definition for replacing table #20131

Merged
merged 11 commits into from
Jan 17, 2025
Next Next commit
add todos to all usages to replace
  • Loading branch information
BugenZhao committed Jan 17, 2025
commit ae5a320759a0e536a4920cb944d5e9b173d66545
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async fn read_relation_info(reader: &SysCatalogReaderImpl) -> Result<Vec<RwRelat
schemaname: schema.clone(),
relationname: t.name.clone(),
relationowner: t.owner as i32,
definition: t.definition.clone(),
definition: t.create_sql(),
relationtype: "MATERIALIZED VIEW".into(),
relationid: t.id.table_id as i32,
relationtimezone: fragments.get_ctx().unwrap().get_timezone().clone(),
Expand All @@ -106,7 +106,7 @@ async fn read_relation_info(reader: &SysCatalogReaderImpl) -> Result<Vec<RwRelat
schemaname: schema.clone(),
relationname: t.name.clone(),
relationowner: t.owner as i32,
definition: t.definition.clone(),
definition: t.create_sql_purified(),
relationtype: "TABLE".into(),
relationid: t.id.table_id as i32,
relationtimezone: fragments.get_ctx().unwrap().get_timezone().clone(),
Expand Down Expand Up @@ -144,7 +144,7 @@ async fn read_relation_info(reader: &SysCatalogReaderImpl) -> Result<Vec<RwRelat
schemaname: schema.clone(),
relationname: t.name.clone(),
relationowner: t.index_table.owner as i32,
definition: t.index_table.definition.clone(),
definition: t.index_table.create_sql(),
relationtype: "INDEX".into(),
relationid: t.index_table.id.table_id as i32,
relationtimezone: fragments.get_ctx().unwrap().get_timezone().clone(),
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/handler/alter_table_column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub async fn get_new_table_definition_for_cdc_table(
);

// Retrieve the original table definition.
// TODO(purify): use purified definition.
let mut definition = original_catalog.create_sql_ast()?;

// Clear the original columns field, so that we'll follow `new_columns` to generate a
Expand Down Expand Up @@ -257,6 +258,7 @@ pub async fn handle_alter_table_column(
}

// Retrieve the original table definition and parse it to AST.
// TODO(purify): use purified definition.
let mut definition = original_catalog.create_sql_ast()?;
let Statement::CreateTable {
columns,
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/handler/alter_table_with_sr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::error::{ErrorCode, Result};
use crate::TableCatalog;

fn get_format_encode_from_table(table: &TableCatalog) -> Result<Option<FormatEncodeOptions>> {
// TODO(purify): use purified definition.
let stmt = table.create_sql_ast()?;
let Statement::CreateTable { format_encode, .. } = stmt else {
unreachable!()
Expand Down Expand Up @@ -63,6 +64,7 @@ pub async fn handle_refresh_schema(
};

// NOTE(st1page): since we have not implemented alter format encode for table, it is actually no use.
// TODO(purify): use purified definition.
let definition = alter_definition_format_encode(
&original_table.definition,
format_encode.row_options.clone(),
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/handler/create_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ pub(crate) async fn reparse_table_for_sink(
table_catalog: &Arc<TableCatalog>,
) -> Result<(StreamFragmentGraph, Table, Option<PbSource>)> {
// Retrieve the original table definition and parse it to AST.
// TODO(purify): use purified definition.
let definition = table_catalog.create_sql_ast()?;
let Statement::CreateTable {
name,
Expand Down