apache / apache/iceberg

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

Open
#16,581 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
9.2k
Forks
3.5k
Avg merge
2d 11h
Merged PRs (30d)
132

Description

### 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:

```java
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?

Contributor guide

Open the contributing guide

Research direction

Start in the SchemaUpdate implementation and trace how renameColumn and moveFirst resolve column names when chained in one update. Reproduce the provided rename-then-move example, then inspect existing schema-update tests or add a focused regression case; done should establish and verify the intended behavior for the renamed name.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.