File tree Expand file tree Collapse file tree 5 files changed +25
-9
lines changed
integration_tests/tests/shared_tests Expand file tree Collapse file tree 5 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -129,10 +129,26 @@ impl<'a> Transaction<'a> {
129
129
/// Creates a fast append action.
130
130
pub fn fast_append (
131
131
self ,
132
+ snapshot_id : Option < i64 > ,
132
133
commit_uuid : Option < Uuid > ,
133
134
key_metadata : Vec < u8 > ,
134
135
) -> Result < FastAppendAction < ' a > > {
135
- let snapshot_id = self . generate_unique_snapshot_id ( ) ;
136
+ let snapshot_id = if let Some ( snapshot_id) = snapshot_id {
137
+ if self
138
+ . table
139
+ . metadata ( )
140
+ . snapshots ( )
141
+ . any ( |s| s. snapshot_id ( ) == snapshot_id)
142
+ {
143
+ return Err ( Error :: new (
144
+ ErrorKind :: DataInvalid ,
145
+ format ! ( "Snapshot id {} already exists" , snapshot_id) ,
146
+ ) ) ;
147
+ }
148
+ snapshot_id
149
+ } else {
150
+ self . generate_unique_snapshot_id ( )
151
+ } ;
136
152
FastAppendAction :: new (
137
153
self ,
138
154
snapshot_id,
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ async fn test_append_data_file() {
112
112
113
113
// commit result
114
114
let tx = Transaction :: new ( & table) ;
115
- let mut append_action = tx. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
115
+ let mut append_action = tx. fast_append ( None , None , vec ! [ ] ) . unwrap ( ) ;
116
116
append_action. add_data_files ( data_file. clone ( ) ) . unwrap ( ) ;
117
117
let tx = append_action. apply ( ) . await . unwrap ( ) ;
118
118
let table = tx. commit ( & rest_catalog) . await . unwrap ( ) ;
@@ -132,7 +132,7 @@ async fn test_append_data_file() {
132
132
133
133
// commit result again
134
134
let tx = Transaction :: new ( & table) ;
135
- let mut append_action = tx. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
135
+ let mut append_action = tx. fast_append ( None , None , vec ! [ ] ) . unwrap ( ) ;
136
136
append_action. add_data_files ( data_file. clone ( ) ) . unwrap ( ) ;
137
137
let tx = append_action. apply ( ) . await . unwrap ( ) ;
138
138
let table = tx. commit ( & rest_catalog) . await . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ async fn test_append_partition_data_file() {
119
119
120
120
// commit result
121
121
let tx = Transaction :: new ( & table) ;
122
- let mut append_action = tx. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
122
+ let mut append_action = tx. fast_append ( None , None , vec ! [ ] ) . unwrap ( ) ;
123
123
append_action
124
124
. add_data_files ( data_file_valid. clone ( ) )
125
125
. unwrap ( ) ;
@@ -178,7 +178,7 @@ async fn test_schema_incompatible_partition_type(
178
178
let data_file_invalid = data_file_writer_invalid. close ( ) . await . unwrap ( ) ;
179
179
180
180
let tx = Transaction :: new ( & table) ;
181
- let mut append_action = tx. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
181
+ let mut append_action = tx. fast_append ( None , None , vec ! [ ] ) . unwrap ( ) ;
182
182
if append_action
183
183
. add_data_files ( data_file_invalid. clone ( ) )
184
184
. is_ok ( )
@@ -217,7 +217,7 @@ async fn test_schema_incompatible_partition_fields(
217
217
let data_file_invalid = data_file_writer_invalid. close ( ) . await . unwrap ( ) ;
218
218
219
219
let tx = Transaction :: new ( & table) ;
220
- let mut append_action = tx. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
220
+ let mut append_action = tx. fast_append ( None , None , vec ! [ ] ) . unwrap ( ) ;
221
221
if append_action
222
222
. add_data_files ( data_file_invalid. clone ( ) )
223
223
. is_ok ( )
Original file line number Diff line number Diff line change @@ -90,12 +90,12 @@ async fn test_append_data_file_conflict() {
90
90
91
91
// start two transaction and commit one of them
92
92
let tx1 = Transaction :: new ( & table) ;
93
- let mut append_action = tx1. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
93
+ let mut append_action = tx1. fast_append ( None , None , vec ! [ ] ) . unwrap ( ) ;
94
94
append_action. add_data_files ( data_file. clone ( ) ) . unwrap ( ) ;
95
95
let tx1 = append_action. apply ( ) . await . unwrap ( ) ;
96
96
97
97
let tx2 = Transaction :: new ( & table) ;
98
- let mut append_action = tx2. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
98
+ let mut append_action = tx2. fast_append ( None , None , vec ! [ ] ) . unwrap ( ) ;
99
99
append_action. add_data_files ( data_file. clone ( ) ) . unwrap ( ) ;
100
100
let tx2 = append_action. apply ( ) . await . unwrap ( ) ;
101
101
let table = tx2
Original file line number Diff line number Diff line change @@ -309,7 +309,7 @@ async fn test_scan_all_type() {
309
309
310
310
// commit result
311
311
let tx = Transaction :: new ( & table) ;
312
- let mut append_action = tx. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
312
+ let mut append_action = tx. fast_append ( None , None , vec ! [ ] ) . unwrap ( ) ;
313
313
append_action. add_data_files ( data_file. clone ( ) ) . unwrap ( ) ;
314
314
let tx = append_action. apply ( ) . await . unwrap ( ) ;
315
315
let table = tx. commit ( & rest_catalog) . await . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments