Skip to content

Commit 036285d

Browse files
committed
throw error when not found
1 parent 2222e99 commit 036285d

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

e2e_test/source_legacy/cdc_inline/sql_server_cdc/sql_server_cdc.slt

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ CREATE TABLE shared_orders (
207207
) from mssql_source table 'mydb.dbo.orders';
208208

209209
# column name mismatch
210-
statement error INVALID_ARGUMENT: Column 'wrong_order_date' not found in the upstream database
210+
statement error Column 'wrong_order_date' not found in the upstream database
211211
CREATE TABLE shared_orders (
212212
order_id INT,
213213
wrong_order_date BIGINT,

src/frontend/src/handler/create_table.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -1181,28 +1181,25 @@ pub(super) async fn handle_create_table_plan(
11811181
let table: ExternalTableImpl = ExternalTableImpl::connect(config)
11821182
.await
11831183
.context("failed to auto derive table schema")?;
1184-
let external_columns: HashMap<&str, ColumnCatalog> = table
1184+
let external_columns: HashMap<&str, &ColumnDesc> = table
11851185
.column_descs()
11861186
.iter()
1187-
.map(|column_desc| {
1188-
(
1189-
column_desc.name(),
1190-
ColumnCatalog {
1191-
column_desc: column_desc.clone(),
1192-
is_hidden: false,
1193-
},
1194-
)
1195-
})
1187+
.map(|column_desc| (column_desc.name.as_str(), column_desc))
11961188
.collect();
11971189

11981190
for col in &mut columns {
1199-
let external_col = external_columns.get(col.name()).ok_or_else(|| {
1200-
ErrorCode::ConnectorError(
1201-
format!("Column {} not found in external table", col.name()).into(),
1202-
)
1203-
})?;
1191+
let external_column_desc =
1192+
*external_columns.get(col.name()).ok_or_else(|| {
1193+
ErrorCode::ConnectorError(
1194+
format!(
1195+
"Column '{}' not found in the upstream database",
1196+
col.name()
1197+
)
1198+
.into(),
1199+
)
1200+
})?;
12041201
col.column_desc.generated_or_default_column =
1205-
external_col.column_desc.generated_or_default_column.clone();
1202+
external_column_desc.generated_or_default_column.clone();
12061203
}
12071204
(columns, pk_names)
12081205
}

0 commit comments

Comments
 (0)