Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1530,12 +1530,17 @@ public void dropColumn(ConnectorSession session, ConnectorTableHandle tableHandl
{
IcebergColumnHandle handle = (IcebergColumnHandle) column;
Table icebergTable = catalog.loadTable(session, ((IcebergTableHandle) tableHandle).getSchemaTableName());
boolean isPartitionColumn = icebergTable.spec().fields().stream()
.anyMatch(field -> field.sourceId() == handle.getId() && !isVoidTransform(field));
if (isPartitionColumn) {
Optional<PartitionField> partitionField = icebergTable.spec().fields().stream()
.filter(field -> field.sourceId() == handle.getId()).findAny();
if (partitionField.isPresent() && !isVoidTransform(partitionField.get())) {
throw new TrinoException(NOT_SUPPORTED, "Cannot drop partition field: " + handle.getName());
}
try {
if (partitionField.isPresent()) {
icebergTable.updateSpec()
.removeField(partitionField.get().name())
.commit();
}
icebergTable.updateSchema()
.deleteColumn(handle.getName())
.commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,16 @@ public void testAddNotNullColumnToNonEmptyTable()
}
}

@Test
public void tesInsertAfterDropVoidPartitionColumn()
{
String tableName = "test_drop_partition_column_" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " (id INTEGER, name VARCHAR) WITH (partitioning = ARRAY['id', 'void(name)'])");
assertUpdate("ALTER TABLE " + tableName + " DROP COLUMN name");
assertUpdate("INSERT INTO " + tableName + " VALUES (1)", 1);
dropTable(tableName);
}

@Test
public void testSchemaEvolution()
{
Expand Down