Fokko commented on code in PR #5011:
URL: https://github.com/apache/iceberg/pull/5011#discussion_r901994450
##########
python/src/iceberg/types.py:
##########
@@ -181,29 +275,33 @@ class ListType(IcebergType):
ListType(element_id=3, element_type=StringType(),
element_required=True)
"""
- element_id: int = field()
- element_type: IcebergType = field()
- element_required: bool = field(default=True)
- element: NestedField = field(init=False, repr=False)
-
- def __post_init__(self):
- object.__setattr__(
- self,
- "element",
- NestedField(
- name="element",
- required=self.element_required,
- field_id=self.element_id,
- field_type=self.element_type,
- ),
+ class Config:
+ fields = {"element_field": {"exclude": True}}
Review Comment:
Good question! This is because `PrivateField` requires the variable name to
start with an underscore, and these variables shouldn't be used outside of the
class itself. Because we use the `element_field` in the visitor as well, it
makes more sense to make it an actual field, and omit it when we serialize the
`ListType`.
##########
python/tests/conftest.py:
##########
@@ -301,3 +319,81 @@ def all_avro_types() -> Dict[str, Any]:
@pytest.fixture
def catalog() -> InMemoryCatalog:
return InMemoryCatalog("test.in.memory.catalog", {"test.key":
"test.value"})
+
+
[email protected](scope="session")
+def simple_struct():
+ return StructType(
+ NestedField(1, "required_field", StringType(), True, "this is a doc"),
NestedField(2, "optional_field", IntegerType())
Review Comment:
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: [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]