|
26 | 26 | import static org.apache.iceberg.TableProperties.UPDATE_MODE;
|
27 | 27 | import static org.assertj.core.api.Assertions.assertThat;
|
28 | 28 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
| 29 | +import static org.assertj.core.api.Assumptions.assumeThat; |
29 | 30 |
|
30 | 31 | import java.util.List;
|
31 | 32 | import org.apache.iceberg.DataOperations;
|
@@ -79,13 +80,11 @@ public void testDataFilters() {
|
79 | 80 | sql("INSERT INTO %s VALUES (1, 'c'), (2, 'c'), (3, 'c')", tableName);
|
80 | 81 |
|
81 | 82 | Table table = validationCatalog.loadTable(tableIdent);
|
82 |
| - |
83 | 83 | Snapshot snap1 = table.currentSnapshot();
|
84 | 84 |
|
85 | 85 | sql("DELETE FROM %s WHERE id = 3", tableName);
|
86 | 86 |
|
87 | 87 | table.refresh();
|
88 |
| - |
89 | 88 | Snapshot snap2 = table.currentSnapshot();
|
90 | 89 |
|
91 | 90 | assertEquals(
|
@@ -123,13 +122,11 @@ public void testUpdates() {
|
123 | 122 | createTableWithDefaultRows();
|
124 | 123 |
|
125 | 124 | Table table = validationCatalog.loadTable(tableIdent);
|
126 |
| - |
127 | 125 | Snapshot snap2 = table.currentSnapshot();
|
128 | 126 |
|
129 | 127 | sql("UPDATE %s SET id = -2 WHERE data = 'b'", tableName);
|
130 | 128 |
|
131 | 129 | table.refresh();
|
132 |
| - |
133 | 130 | Snapshot snap3 = table.currentSnapshot();
|
134 | 131 |
|
135 | 132 | assertEquals(
|
@@ -295,6 +292,42 @@ public void testManifestRewritesAreIgnored() {
|
295 | 292 | sql("SELECT id, _change_type FROM %s.changes ORDER BY id", tableName));
|
296 | 293 | }
|
297 | 294 |
|
| 295 | + @TestTemplate |
| 296 | + public void testDataRewritesAreIgnored() { |
| 297 | + assumeThat(formatVersion).isEqualTo(2); |
| 298 | + |
| 299 | + createTable(); |
| 300 | + sql("INSERT INTO %s VALUES (1, 'c'), (2, 'c'), (3, 'c')", tableName); |
| 301 | + |
| 302 | + Table table = validationCatalog.loadTable(tableIdent); |
| 303 | + Snapshot snap1 = table.currentSnapshot(); |
| 304 | + |
| 305 | + sql("DELETE FROM %s WHERE id = 3", tableName); |
| 306 | + |
| 307 | + table.refresh(); |
| 308 | + Snapshot snap2 = table.currentSnapshot(); |
| 309 | + |
| 310 | + sql( |
| 311 | + "CALL %s.system.rewrite_data_files(table => '%s', " |
| 312 | + + "options => map('delete-file-threshold','1'))", |
| 313 | + catalogName, tableIdent); |
| 314 | + |
| 315 | + sql("DELETE FROM %s WHERE id = 1", tableName); |
| 316 | + |
| 317 | + table.refresh(); |
| 318 | + Snapshot snap3 = table.currentSnapshot(); |
| 319 | + |
| 320 | + assertEquals( |
| 321 | + "Should have expected rows", |
| 322 | + ImmutableList.of( |
| 323 | + row(1, "c", "INSERT", 0, snap1.snapshotId()), |
| 324 | + row(2, "c", "INSERT", 0, snap1.snapshotId()), |
| 325 | + row(3, "c", "INSERT", 0, snap1.snapshotId()), |
| 326 | + row(3, "c", "DELETE", 1, snap2.snapshotId()), |
| 327 | + row(1, "c", "DELETE", 2, snap3.snapshotId())), |
| 328 | + sql("SELECT * FROM %s.changes ORDER BY _change_ordinal, id, _change_type", tableName)); |
| 329 | + } |
| 330 | + |
298 | 331 | @TestTemplate
|
299 | 332 | public void testMetadataColumns() {
|
300 | 333 | createTableWithDefaultRows();
|
|
0 commit comments