kevinjqliu commented on code in PR #2798:
URL: https://github.com/apache/iceberg-python/pull/2798#discussion_r2725825762
##########
tests/table/test_init.py:
##########
@@ -627,6 +627,54 @@ def test_add_nested_list_type_column(table_v2: Table) ->
None:
assert new_schema.highest_field_id == 7
+def test_update_list_element_required(table_v2: Table) -> None:
+ """Test that update_column can change list element's required property."""
+ # Add a list column with optional elements
+ update = UpdateSchema(transaction=table_v2.transaction())
+ list_type = ListType(element_id=1, element_type=StringType(),
element_required=False)
+ update.add_column(path="tags", field_type=list_type)
+ schema_with_list = update._apply()
+
+ # Verify initial state
+ field = schema_with_list.find_field("tags")
+ assert isinstance(field.field_type, ListType)
+ assert field.field_type.element_required is False
+
+ # Update element to required
+ update2 = UpdateSchema(transaction=table_v2.transaction(),
schema=schema_with_list)
+ update2._allow_incompatible_changes = True # Allow optional -> required
Review Comment:
thanks for adding this
optional -> required is incompatible and thus requires the flag
https://github.com/apache/iceberg-python/blob/bad9cda1027068cf9720e3bb9f0b24d4279b13e8/pyiceberg/table/update/schema.py#L368-L369
--
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]