huan233usc opened a new pull request, #17034:
URL: https://github.com/apache/iceberg/pull/17034
## Problem
`SchemaUpdate` records a column added in the current transaction in
`addedNameToId`, keyed by the column's name, so that a later operation in the
same transaction (`updateColumn`, `updateColumnDoc`, `requireColumn`,
`makeColumnOptional`, or a move) can resolve the not-yet-committed column.
For a column added into a **map value struct** or a **list element struct**,
`internalAddColumn` builds the key from the parent's canonical name via
`schema.findColumnName(parentId)`, which includes the synthetic `value` /
`element` segment:
```java
fullName = schema.findColumnName(parentId) + "." + name; // e.g.
"locations.value.alt"
addedNameToId.put(caseSensitivityAwareName(fullName), newId);
```
But callers address such a column by its **user-facing short name**
(`locations.alt`, `points.z`) — the form the schema's own name index exposes
for map value / list element structs. `findForUpdate` first tries
`findField(name)` (which can't see the pending column) and then falls back to
`addedNameToId.get(name)`, so the lookup misses and the operation fails with
`Cannot update missing column: locations.alt`.
Only the full canonical path (`locations.value.alt`) works today, which is
not the name users write.
## Example
```java
new SchemaUpdate(schema, lastColumnId)
.addColumn("locations", "alt", Types.FloatType.get()) // into a map<...,
struct> value
.updateColumnDoc("locations.alt", "altitude") // ->
IllegalArgumentException today
.apply();
```
## Fix
Also index the user-facing short name in `addedNameToId` for nested adds, so
the shorthand resolves. This mirrors how the schema's own `IndexByName` tracks
both the full and short paths (dropping `value`/`element` for structs nested in
a map value / list element). Top-level and plain-struct adds are unaffected
because their short name equals the full name.
## Tests
Added
`TestSchemaUpdate.testUpdateColumnAddedToMapValueOrListElementInSameTransaction`:
adds a field into a map value struct and a list element struct, then
references each by its short name (`locations.alt`, `points.z`) in the same
transaction. It fails before the change with `Cannot update missing column` and
passes after. The full `TestSchemaUpdate` suite remains green.
--
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]