You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "xixipi-lining (via GitHub)" <gi...@apache.org> on 2025/08/01 11:58:54 UTC

[PR] feat(name_mapping): Add CreateNameMappingFromSchema and UpdateNameMapping functions [iceberg-go]

xixipi-lining opened a new pull request, #521:
URL: https://github.com/apache/iceberg-go/pull/521

   ## Description
   Adds CreateNameMappingFromSchema and UpdateNameMapping functions to the name mapping, following the same implementation pattern as iceberg-python.
   ## Changes
   - CreateNameMappingFromSchema: Creates name mappings from schema by traversing the schema structure
   - UpdateNameMapping: Updates existing name mappings with field changes and additions
   - test coverage: Includes tests for nested structures, field updates, and additions


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add UpdateNameMapping function [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #521:
URL: https://github.com/apache/iceberg-go/pull/521#discussion_r2257793030


##########
name_mapping.go:
##########
@@ -130,6 +130,122 @@ func visitMappedFields[S, T any](fields []MappedField, visitor NameMappingVisito
 	return visitor.Fields(fields, results)
 }
 
+func UpdateNameMapping(nameMapping NameMapping, updates map[int]NestedField, adds map[int][]NestedField) (NameMapping, error) {
+	result, err := VisitNameMapping(nameMapping, &updateNameMappingVisitor{updates: updates, adds: adds})

Review Comment:
   Add a docstsring comment here to explain the benefits of using this vs just `CreateNameMapping` etc.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add CreateNameMappingFromSchema and UpdateNameMapping functions [iceberg-go]

Posted by "xixipi-lining (via GitHub)" <gi...@apache.org>.
xixipi-lining commented on PR #521:
URL: https://github.com/apache/iceberg-go/pull/521#issuecomment-3157317823

   Hi @zeroshade,
   
   The main purpose of this PR is to add the `UpdateNameMapping` function. This functionality was missing from the codebase and is essential for schema evolution scenarios.
   
   I initially missed that `createMapping` functionality already existed and accidentally introduced duplicate code. I've now removed the duplicate implementations and kept only the new `UpdateNameMapping` functionality.
   
   Thanks for the review!


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add UpdateNameMapping function [iceberg-go]

Posted by "xixipi-lining (via GitHub)" <gi...@apache.org>.
xixipi-lining commented on PR #521:
URL: https://github.com/apache/iceberg-go/pull/521#issuecomment-3160830511

   The key difference is that UpdateNameMapping preserves existing name mappings while adding new ones. For example:
   ```
   // Original: {FieldID: 1, Names: ["foo"]}
   // After update: {FieldID: 1, Names: ["foo", "foo_update"]}
   ```
   This maintains backward compatibility by keeping the old name while adding the new one, rather than replacing it entirely.
   
   If I understand name mappings correctly, they're used to map field names to field IDs when schemas don't have explicit IDs (like in Arrow schemas). So preserving existing name mappings during schema evolution is important for compatibility with existing data files that might reference the old field names.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add UpdateNameMapping function [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #521:
URL: https://github.com/apache/iceberg-go/pull/521


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add UpdateNameMapping function [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #521:
URL: https://github.com/apache/iceberg-go/pull/521#issuecomment-3160679982

   So what's the benefit to using `UpdateMapping` versus just creating a new mapping?


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add UpdateNameMapping function [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #521:
URL: https://github.com/apache/iceberg-go/pull/521#issuecomment-3160911066

   Ah! That makes sense, thanks!


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add UpdateNameMapping function [iceberg-go]

Posted by "xixipi-lining (via GitHub)" <gi...@apache.org>.
xixipi-lining commented on PR #521:
URL: https://github.com/apache/iceberg-go/pull/521#issuecomment-3160726687

   Since iceberg-go doesn't have schema evolution yet, UpdateNameMapping might seem premature.
   But when we add schema evolution later, this function will be needed for updating name mappings incrementally.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add CreateNameMappingFromSchema and UpdateNameMapping functions [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #521:
URL: https://github.com/apache/iceberg-go/pull/521#issuecomment-3156349950

   There is already a `createMappingFromSchema` function at https://github.com/apache/iceberg-go/blob/main/name_mapping.go#L361 so we don't need a new one and a new visitor (the current one is already based on the python pattern :smile:)


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(name_mapping): Add UpdateNameMapping function [iceberg-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #521:
URL: https://github.com/apache/iceberg-go/pull/521#issuecomment-3160780558

   That's kinda my question, does it actually make sense to incrementally update the name mappings rather than simply re-create an entire new mapping from the updated schema?


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org