rambleraptor commented on code in PR #4353:
URL: https://github.com/apache/iceberg-python/pull/4353#discussion_r4556008551


##########
pyiceberg/catalog/rest/__init__.py:
##########
@@ -376,6 +375,16 @@ class TableResponse(IcebergBaseModel):
     storage_credentials: list[StorageCredential] = 
Field(alias="storage-credentials", default_factory=list)
     labels: Labels = Field(default_factory=Labels)
 
+    @field_validator("config", mode="before")

Review Comment:
   This feels really messy. I'm personally not a huge fan of field_validators 
being appended onto models, since it can be hard to understand the control flow.
   
   What if we created a new type like `NullableList` that has this property 
built in. Then, we can just change the Field type. As a bonus, we can then 
reuse it throughout.
   
   It would look something like:
   
   ```
   def _empty_if_none(factory: Callable[[], Any]) -> BeforeValidator:
       return BeforeValidator(lambda v: factory() if v is None else v)
   
   # A JSON null is read as an empty map / list, like Java's `hasNonNull`
   NullableList = Annotated[list[T], _empty_if_none(list)]
   ```



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