Shruthirdy commented on code in PR #2714:
URL: https://github.com/apache/iceberg-go/pull/2714#discussion_r4723188529
##########
table/update_schema.go:
##########
@@ -654,9 +673,51 @@ func (u *UpdateSchema) findFieldForMove(name string) (int,
bool) {
if ok {
return field.ID, true
}
- id, ok := u.addedNameToID[name]
- return id, ok
+ return u.addedFieldID(name)
+}
+
+// addedFieldID returns the ID of a column added earlier in this update,
+// matching the name with UpdateSchema's case sensitivity. AddColumn rejects
+// names that differ only in case, so at most one matches.
+func (u *UpdateSchema) addedFieldID(name string) (int, bool) {
+ if id, ok := u.addedNameToID[name]; ok {
+ return id, true
+ }
+ for addedName, id := range u.addedNameToID {
+ if u.sameName(addedName, name) {
+ return id, true
+ }
+ }
+
+ return 0, false
+}
+
+// findFieldForUpdate finds a field in the original schema, or falls back to a
+// column added earlier in this update. For an added field it also returns
+// a pointer to its entry in u.adds, so the caller can update it in place.
+// For a field in the original schema the pointer is nil.
+func (u *UpdateSchema) findFieldForUpdate(name string) (iceberg.NestedField,
*iceberg.NestedField, bool) {
Review Comment:
It now returns the parent ID and index instead of a pointer, and the
write-back indexes `u.adds` directly, so it no longer depends on nothing
appending in between.
--
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]