iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

SchemaUpdate cannot move a column by its new name after renameColumn in the same update

Open TwinklerG opened this issue 6 months ago • 1 comments

Query engine

It does not matter.

Question

When using UpdateSchema, I noticed a column cannot be moved(or any other similar operation) by its new name after it has been renamed in the same SchemaUpdate.

For example:

Schema newSchema =
        new SchemaUpdate(schemaWithIdentifierFields, SCHEMA_LAST_COLUMN_ID)
                .renameColumn("data", "data_renamed")
                .moveFirst("data_renamed")
                .apply();

This fails with: Cannot move missing column: data_renamed.(Actually I have to use the original name data in moveFirst method).

Is this the intended behavior of UpdateSchema, where subsequent operations in the same update should continue to refer to renamed columns by their original names? Or should SchemaUpdate also allow resolving pending renamed names for move operations within the same update?

TwinklerG avatar May 27 '26 11:05 TwinklerG

I'd like to pick this up. It's the same problem as #10830, where @RussellSpitzer and @Fokko agreed it isn't intended, and #12202 tried to fix it before the stale bot closed it. My plan is for SchemaUpdate to also resolve a column's pending new name in the update and move methods (updateColumn, updateColumnDoc, requireColumn, makeColumnOptional, updateColumnDefault, moveFirst, moveBefore, moveAfter), only when the name doesn't match an existing or added column, so original names keep working as they do today.

yusufyildiz34 avatar Oct 23 '26 18:10 yusufyildiz34