@@ -597,111 +597,120 @@ impl TableRequirement {
597
597
match self {
598
598
TableRequirement :: NotExist => {
599
599
return Err ( Error :: new (
600
- ErrorKind :: DataInvalid ,
600
+ ErrorKind :: CatalogCommitConflicts ,
601
601
format ! (
602
602
"Requirement failed: Table with id {} already exists" ,
603
603
metadata. uuid( )
604
604
) ,
605
- ) ) ;
605
+ )
606
+ . with_retryable ( true ) ) ;
606
607
}
607
608
TableRequirement :: UuidMatch { uuid } => {
608
609
if & metadata. uuid ( ) != uuid {
609
610
return Err ( Error :: new (
610
- ErrorKind :: DataInvalid ,
611
+ ErrorKind :: CatalogCommitConflicts ,
611
612
"Requirement failed: Table UUID does not match" ,
612
613
)
613
614
. with_context ( "expected" , * uuid)
614
- . with_context ( "found" , metadata. uuid ( ) ) ) ;
615
+ . with_context ( "found" , metadata. uuid ( ) )
616
+ . with_retryable ( true ) ) ;
615
617
}
616
618
}
617
619
TableRequirement :: CurrentSchemaIdMatch { current_schema_id } => {
618
620
// ToDo: Harmonize the types of current_schema_id
619
621
if metadata. current_schema_id != * current_schema_id {
620
622
return Err ( Error :: new (
621
- ErrorKind :: DataInvalid ,
623
+ ErrorKind :: CatalogCommitConflicts ,
622
624
"Requirement failed: Current schema id does not match" ,
623
625
)
624
626
. with_context ( "expected" , current_schema_id. to_string ( ) )
625
- . with_context ( "found" , metadata. current_schema_id . to_string ( ) ) ) ;
627
+ . with_context ( "found" , metadata. current_schema_id . to_string ( ) )
628
+ . with_retryable ( true ) ) ;
626
629
}
627
630
}
628
631
TableRequirement :: DefaultSortOrderIdMatch {
629
632
default_sort_order_id,
630
633
} => {
631
634
if metadata. default_sort_order ( ) . order_id != * default_sort_order_id {
632
635
return Err ( Error :: new (
633
- ErrorKind :: DataInvalid ,
636
+ ErrorKind :: CatalogCommitConflicts ,
634
637
"Requirement failed: Default sort order id does not match" ,
635
638
)
636
639
. with_context ( "expected" , default_sort_order_id. to_string ( ) )
637
- . with_context (
638
- "found" ,
639
- metadata. default_sort_order ( ) . order_id . to_string ( ) ,
640
- ) ) ;
640
+ . with_context ( "found" , metadata. default_sort_order ( ) . order_id . to_string ( ) )
641
+ . with_retryable ( true ) ) ;
641
642
}
642
643
}
643
644
TableRequirement :: RefSnapshotIdMatch { r#ref, snapshot_id } => {
644
645
let snapshot_ref = metadata. snapshot_for_ref ( r#ref) ;
645
646
if let Some ( snapshot_id) = snapshot_id {
646
- let snapshot_ref = snapshot_ref. ok_or ( Error :: new (
647
- ErrorKind :: DataInvalid ,
648
- format ! ( "Requirement failed: Branch or tag `{}` not found" , r#ref) ,
649
- ) ) ?;
647
+ let snapshot_ref = snapshot_ref. ok_or (
648
+ Error :: new (
649
+ ErrorKind :: CatalogCommitConflicts ,
650
+ format ! ( "Requirement failed: Branch or tag `{}` not found" , r#ref) ,
651
+ )
652
+ . with_retryable ( true ) ,
653
+ ) ?;
650
654
if snapshot_ref. snapshot_id ( ) != * snapshot_id {
651
655
return Err ( Error :: new (
652
- ErrorKind :: DataInvalid ,
656
+ ErrorKind :: CatalogCommitConflicts ,
653
657
format ! (
654
658
"Requirement failed: Branch or tag `{}`'s snapshot has changed" ,
655
659
r#ref
656
660
) ,
657
661
)
658
662
. with_context ( "expected" , snapshot_id. to_string ( ) )
659
- . with_context ( "found" , snapshot_ref. snapshot_id ( ) . to_string ( ) ) ) ;
663
+ . with_context ( "found" , snapshot_ref. snapshot_id ( ) . to_string ( ) )
664
+ . with_retryable ( true ) ) ;
660
665
}
661
666
} else if snapshot_ref. is_some ( ) {
662
667
// a null snapshot ID means the ref should not exist already
663
668
return Err ( Error :: new (
664
- ErrorKind :: DataInvalid ,
669
+ ErrorKind :: CatalogCommitConflicts ,
665
670
format ! (
666
671
"Requirement failed: Branch or tag `{}` already exists" ,
667
672
r#ref
668
673
) ,
669
- ) ) ;
674
+ )
675
+ . with_retryable ( true ) ) ;
670
676
}
671
677
}
672
678
TableRequirement :: DefaultSpecIdMatch { default_spec_id } => {
673
679
// ToDo: Harmonize the types of default_spec_id
674
680
if metadata. default_partition_spec_id ( ) != * default_spec_id {
675
681
return Err ( Error :: new (
676
- ErrorKind :: DataInvalid ,
682
+ ErrorKind :: CatalogCommitConflicts ,
677
683
"Requirement failed: Default partition spec id does not match" ,
678
684
)
679
685
. with_context ( "expected" , default_spec_id. to_string ( ) )
680
- . with_context ( "found" , metadata. default_partition_spec_id ( ) . to_string ( ) ) ) ;
686
+ . with_context ( "found" , metadata. default_partition_spec_id ( ) . to_string ( ) )
687
+ . with_retryable ( true ) ) ;
681
688
}
682
689
}
683
690
TableRequirement :: LastAssignedPartitionIdMatch {
684
691
last_assigned_partition_id,
685
692
} => {
686
693
if metadata. last_partition_id != * last_assigned_partition_id {
687
694
return Err ( Error :: new (
688
- ErrorKind :: DataInvalid ,
695
+ ErrorKind :: CatalogCommitConflicts ,
689
696
"Requirement failed: Last assigned partition id does not match" ,
690
697
)
691
698
. with_context ( "expected" , last_assigned_partition_id. to_string ( ) )
692
- . with_context ( "found" , metadata. last_partition_id . to_string ( ) ) ) ;
699
+ . with_context ( "found" , metadata. last_partition_id . to_string ( ) )
700
+ . with_retryable ( true ) ) ;
693
701
}
694
702
}
695
703
TableRequirement :: LastAssignedFieldIdMatch {
696
704
last_assigned_field_id,
697
705
} => {
698
706
if & metadata. last_column_id != last_assigned_field_id {
699
707
return Err ( Error :: new (
700
- ErrorKind :: DataInvalid ,
708
+ ErrorKind :: CatalogCommitConflicts ,
701
709
"Requirement failed: Last assigned field id does not match" ,
702
710
)
703
711
. with_context ( "expected" , last_assigned_field_id. to_string ( ) )
704
- . with_context ( "found" , metadata. last_column_id . to_string ( ) ) ) ;
712
+ . with_context ( "found" , metadata. last_column_id . to_string ( ) )
713
+ . with_retryable ( true ) ) ;
705
714
}
706
715
}
707
716
} ;
@@ -710,7 +719,7 @@ impl TableRequirement {
710
719
TableRequirement :: NotExist => { }
711
720
_ => {
712
721
return Err ( Error :: new (
713
- ErrorKind :: DataInvalid ,
722
+ ErrorKind :: TableNotFound ,
714
723
"Requirement failed: Table does not exist" ,
715
724
) ) ;
716
725
}
@@ -814,7 +823,7 @@ pub enum ViewUpdate {
814
823
#[ serde( rename_all = "kebab-case" ) ]
815
824
AssignUuid {
816
825
/// The new UUID to assign.
817
- uuid : uuid :: Uuid ,
826
+ uuid : Uuid ,
818
827
} ,
819
828
/// Upgrade view's format version
820
829
#[ serde( rename_all = "kebab-case" ) ]
@@ -1092,7 +1101,7 @@ mod tests {
1092
1101
. unwrap ( )
1093
1102
. metadata ;
1094
1103
1095
- // Ref exists and should matches
1104
+ // Ref exists and should match
1096
1105
let requirement = TableRequirement :: RefSnapshotIdMatch {
1097
1106
r#ref : "main" . to_string ( ) ,
1098
1107
snapshot_id : Some ( 3051729675574597004 ) ,
0 commit comments