Shruthirdy opened a new issue, #2633:
URL: https://github.com/apache/iceberg-go/issues/2633
### Apache Iceberg version
main (development)
### Please describe the bug 🐞
`UpdateColumn` can't change a column that was added earlier in the same
`UpdateSchema`. `Apply()` fails with `field not found`:
```go
_, err := NewUpdateSchema(txn, true, true).
AddColumn([]string{"gender"}, iceberg.PrimitiveTypes.String, "", false,
nil).
UpdateColumn([]string{"gender"}, ColumnUpdate{
Doc: iceberg.Optional[string]{Valid: true, Val: "hello"},
}).
Apply()
// err: field not found: gender
```
The same happens for a type, required or write-default change.
`updateColumn` looks the name up with `findField`, which only searches the
table's current schema. The added column is only in `u.adds` and
`u.addedNameToID`, so it isn't found. `MoveColumn` doesn't have this problem,
because `findFieldForMove` falls back to `addedNameToID`.
Java supports this: its update methods use `findForUpdate`, which falls back
to
columns added in the same update
([SchemaUpdate.java(https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/SchemaUpdate.java)),
and `TestSchemaUpdate` covers it in `testUpdateAddedColumnType` and
`testUpdateAddedColumnDoc`.
Renaming an added column is different: Java's `renameColumn` uses
`findField` and rejects it, so `RenameColumn` should keep failing here.
Not the same as #2625, which is about `AddColumn` accepting an existing name.
### Expected
`UpdateColumn` on a column added in the same update applies the change, as
in Java. `RenameColumn` on such a column still returns an error.
### Contribution
I already reproduced this issue locally and would like to work on this issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]