Skip to content

Commit ca0fdf7

Browse files
committed
add errors
1 parent c9bcd66 commit ca0fdf7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

iceberg-rust/src/catalog/commit.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ pub fn apply_table_updates(
445445
if schema_id == -1 {
446446
if let Some(added_schema_id) = added_schema_id {
447447
metadata.current_schema_id = added_schema_id;
448+
} else {
449+
return Err(Error::InvalidFormat(
450+
"Cannot set current schema to -1 without adding a schema first".to_string(),
451+
));
448452
}
449453
} else {
450454
metadata.current_schema_id = schema_id;
@@ -459,6 +463,10 @@ pub fn apply_table_updates(
459463
if spec_id == -1 {
460464
if let Some(added_spec_id) = added_spec_id {
461465
metadata.default_spec_id = added_spec_id;
466+
} else {
467+
return Err(Error::InvalidFormat(
468+
"Cannot set default spec to -1 without adding a spec first".to_string(),
469+
));
462470
}
463471
} else {
464472
metadata.default_spec_id = spec_id;
@@ -473,6 +481,10 @@ pub fn apply_table_updates(
473481
if sort_order_id == -1 {
474482
if let Some(added_sort_order_id) = added_sort_order_id {
475483
metadata.default_sort_order_id = added_sort_order_id;
484+
} else {
485+
return Err(Error::InvalidFormat(
486+
"Cannot set default sort order to -1 without adding a sort order first".to_string(),
487+
));
476488
}
477489
} else {
478490
metadata.default_sort_order_id = sort_order_id;

0 commit comments

Comments
 (0)