Skip to content

Commit db328ec

Browse files
committed
use un-purified sql for sr refresh
Signed-off-by: Bugen Zhao <[email protected]>
1 parent d9fbf84 commit db328ec

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

src/frontend/src/handler/alter_table_with_sr.rs

+15-27
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ use fancy_regex::Regex;
1717
use pgwire::pg_response::{PgResponse, StatementType};
1818
use risingwave_common::bail_not_implemented;
1919
use risingwave_sqlparser::ast::{FormatEncodeOptions, ObjectName, Statement};
20-
use risingwave_sqlparser::parser::Parser;
2120
use thiserror_ext::AsReport;
2221

23-
use super::alter_source_with_sr::alter_definition_format_encode;
2422
use super::alter_table_column::fetch_table_catalog_for_alter;
2523
use super::create_source::schema_has_schema_registry;
2624
use super::util::SourceSchemaCompatExt;
@@ -48,32 +46,22 @@ pub async fn handle_refresh_schema(
4846
bail_not_implemented!("alter table with incoming sinks");
4947
}
5048

51-
let format_encode = {
52-
let format_encode = get_format_encode_from_table(&original_table)?;
53-
if !format_encode
54-
.as_ref()
55-
.is_some_and(schema_has_schema_registry)
56-
{
57-
return Err(ErrorCode::NotSupported(
58-
"tables without schema registry cannot refreshed".to_owned(),
59-
"try `ALTER TABLE .. ADD/DROP COLUMN ...` instead".to_owned(),
60-
)
61-
.into());
62-
}
63-
format_encode.unwrap()
64-
};
65-
66-
// NOTE(st1page): since we have not implemented alter format encode for table, it is actually no use.
67-
// TODO(purify): use purified definition.
68-
let definition = alter_definition_format_encode(
69-
&original_table.definition,
70-
format_encode.row_options.clone(),
71-
)?;
49+
let format_encode = get_format_encode_from_table(&original_table)?;
50+
if !format_encode
51+
.as_ref()
52+
.is_some_and(schema_has_schema_registry)
53+
{
54+
return Err(ErrorCode::NotSupported(
55+
"tables without schema registry cannot be refreshed".to_owned(),
56+
"try `ALTER TABLE .. ADD/DROP COLUMN ...` instead".to_owned(),
57+
)
58+
.into());
59+
}
7260

73-
let [definition]: [_; 1] = Parser::parse_sql(&definition)
74-
.context("unable to parse original table definition")?
75-
.try_into()
76-
.unwrap();
61+
// Not using the purified definition because we want to re-fetch the schema.
62+
let definition = original_table
63+
.create_sql_ast()
64+
.context("unable to parse original table definition")?;
7765

7866
let (source, table, graph, col_index_mapping, job_type) = {
7967
let result =

0 commit comments

Comments
 (0)