Skip to content

Commit b156fff

Browse files
Islam IsmailovIslam Ismailov
andauthored
Core: Allow dropping a column used by old SortOrder (#6211)
Co-authored-by: Islam Ismailov <[email protected]>
1 parent bfdd9b2 commit b156fff

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

core/src/test/java/org/apache/iceberg/TestSortOrder.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,26 @@ public void testSchemaEvolutionWithSortOrder() {
302302
Assert.assertEquals("Field id must match", 2, actualOrder.fields().get(1).sourceId());
303303
}
304304

305+
@Test
306+
public void testColumnDropWithSortOrder() {
307+
PartitionSpec spec = PartitionSpec.unpartitioned();
308+
309+
TestTables.TestTable table = TestTables.create(tableDir, "test", SCHEMA, spec, formatVersion);
310+
311+
int initialColSize = table.schema().columns().size();
312+
313+
table.replaceSortOrder().asc("id").commit();
314+
table.replaceSortOrder().asc("data").commit();
315+
316+
table.updateSchema().deleteColumn("id").commit();
317+
318+
SortOrder actualOrder = table.sortOrder();
319+
Assert.assertEquals(
320+
"Order ID must match", TableMetadata.INITIAL_SORT_ORDER_ID + 1, actualOrder.orderId());
321+
Assert.assertEquals(
322+
"Schema must have one less column", initialColSize - 1, table.schema().columns().size());
323+
}
324+
305325
@Test
306326
public void testIncompatibleSchemaEvolutionWithSortOrder() {
307327
PartitionSpec spec = PartitionSpec.unpartitioned();

0 commit comments

Comments
 (0)