Shruthirdy opened a new pull request, #2714:
URL: https://github.com/apache/iceberg-go/pull/2714

   Closes #2633.
   
   `UpdateColumn` failed with `field not found` on a column added earlier in the
   same `UpdateSchema`, because `updateColumn` only searched the table's current
   schema. Java's `SchemaUpdate.findForUpdate` falls back to pending adds
   (`testUpdateAddedColumnType`, `testUpdateAddedColumnDoc`).
   
   Before:
   ```
   field not found: gender
   ```
   
   After: the doc, type, required or write-default change is applied to the 
added column.
   
   ### Change
   
   - `findFieldForUpdate` falls back to columns added in this update.
   - Renaming an added column is still rejected, as in Java, through both
     `RenameColumn` and `UpdateColumn` with `Name`. The error changes from
     `field not found: X` to `cannot rename a column added in the same update: 
X`.
   - An added column with an initial default can be made required without
     `allowIncompatibleChanges`, as in Java's `isDefaultedAdd`. A write default
     alone isn't enough, and existing columns are still rejected.
   - **Case sensitivity:** `addedNameToID` is keyed by the name as added, so a
     case-insensitive lookup of an added column failed. The new `addedFieldID`
     matches with the update's case sensitivity, which has the same effect as
     Java's `caseSensitivityAwareName`. `findFieldForMove` uses it too, so moves
     now find an added column case-insensitively, both as the moved column and 
as
     the relative-to column (Java's 
`testCaseInsensitiveMoveAfterNewlyAddedField`).
   
   ### Approach
   
   `updateColumn` edits the pending add in `u.adds` in place, rather than 
writing
   to `u.updates`. The Apply visitor appends added fields as they are and never
   applies `u.updates` to them, so this needs no visitor change. The trade-off 
is
   that an added column now sees its own earlier pending changes, while an
   existing column is still checked against the original schema (first
   follow-up below).
   
   ### Unchanged
   
   Updates and renames of existing columns, deletes, name mapping, and
   case-sensitive lookups. `UnionByNameWith` still matches against the current
   schema only.
   
   ### Testing
   
   `TestUpdateColumnAddedInSameUpdate` covers each change above, plus a nested
   column, union-added columns, and a deleted and re-added column. Reverting any
   part of the change fails its tests.
   
   ### Follow-ups
   
   - A second `UpdateColumn` on an existing column validates against the 
original
     field, not the pending change. For example, int→long and then a long write
     default fails. Java's `findForUpdate` returns the pending update.
   - Delete, re-add and move fails with
     `field that has been deleted cannot be moved`; Java's `findForMove` checks
     added columns first.
   
   **Happy to change the approach on any of the points above if maintainer 
prefer a different one.**
   
   No release note: only calls that used to fail now succeed. The one error that
   remains, for renaming an added column, has new text.
   


-- 
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]

Reply via email to